2015-08-21 22:42:25 +02:00
|
|
|
{% from "users/map.jinja" import users with context -%}
|
|
|
|
|
|
|
|
include:
|
|
|
|
- users
|
|
|
|
|
2015-08-21 22:52:36 +02:00
|
|
|
{% set userfile_dirs = salt['cp.list_master_dirs'](prefix='users/files/user/') -%}
|
|
|
|
{%- for username, user in salt['pillar.get']('users', {}).items() if (user.absent is not defined or not user.absent) -%}
|
2016-06-23 21:43:01 +02:00
|
|
|
{%- set current = salt.user.info(username) -%}
|
2015-08-21 22:52:36 +02:00
|
|
|
{%- set user_files = salt['pillar.get'](('users:' ~ username ~ ':user_files'), {'enabled': False}) -%}
|
|
|
|
{%- set user_group = salt['pillar.get'](('users:' ~ username ~ ':prime_group:name'), username) -%}
|
2016-06-23 21:43:01 +02:00
|
|
|
{%- set user_home = salt['pillar.get'](('users:' ~ username ~ ':home'), current.get('home', '/home/' ~ username )) -%}
|
2017-09-22 05:30:29 +02:00
|
|
|
{%- set user_files_template = salt['pillar.get'](('users:' ~ username ~ ':user_files:template'), None) -%}
|
2017-07-27 15:27:44 +02:00
|
|
|
{%- set user_files_file_mode = salt['pillar.get'](('users:' ~ username ~ ':user_files:file_mode'), False) -%}
|
|
|
|
{%- set user_files_sym_mode = salt['pillar.get'](('users:' ~ username ~ ':user_files:sym_mode'), False) -%}
|
2018-06-21 17:01:01 +02:00
|
|
|
{%- set user_files_exclude_pat = salt['pillar.get'](('users:' ~ username ~ ':user_files:exclude_pat'), False) -%}
|
2015-08-21 22:42:25 +02:00
|
|
|
{%- if user_files.enabled -%}
|
|
|
|
|
|
|
|
{%- if user_files.source is defined -%}
|
2015-08-21 22:52:36 +02:00
|
|
|
{%- if user_files.source.startswith('salt://') -%}
|
|
|
|
{%- set file_source = user_files.source -%}
|
|
|
|
{%- else -%}
|
|
|
|
{%- set file_source = ('salt://' ~ user.user_files.source) -%}
|
|
|
|
{%- endif -%}
|
|
|
|
{%- set skip_user = False -%}
|
2015-08-21 22:42:25 +02:00
|
|
|
{%- else -%}
|
2015-08-21 22:52:36 +02:00
|
|
|
{%- if ('users/files/user/' ~ username) in userfile_dirs -%}
|
|
|
|
{%- set file_source = ('salt://users/files/user/' ~ username) -%}
|
|
|
|
{%- set skip_user = False -%}
|
|
|
|
{%- else -%}
|
|
|
|
{%- set skip_user = True -%}
|
|
|
|
{%- endif -%}
|
2015-08-21 22:42:25 +02:00
|
|
|
{%- endif -%}
|
|
|
|
|
2015-08-21 22:52:36 +02:00
|
|
|
{%- if not skip_user %}
|
2015-08-21 22:42:25 +02:00
|
|
|
users_userfiles_{{ username }}_recursive:
|
|
|
|
file.recurse:
|
2015-11-12 18:53:07 +01:00
|
|
|
- name: {{ user_home }}
|
2015-08-21 22:42:25 +02:00
|
|
|
- source: {{ file_source }}
|
|
|
|
- user: {{ username }}
|
|
|
|
- group: {{ user_group }}
|
2017-09-23 00:01:25 +02:00
|
|
|
{% if user_files_template -%}
|
2017-09-22 05:30:29 +02:00
|
|
|
- template: {{ user_files_template }}
|
2017-09-23 00:01:25 +02:00
|
|
|
{% endif -%}
|
2015-08-21 22:42:25 +02:00
|
|
|
- clean: False
|
2017-07-27 15:27:44 +02:00
|
|
|
{% if user_files_file_mode -%}
|
2017-03-23 10:19:06 +01:00
|
|
|
- file_mode: {{ user_files_file_mode }}
|
|
|
|
{% endif -%}
|
2017-07-27 15:27:44 +02:00
|
|
|
{% if user_files_sym_mode -%}
|
2017-03-23 10:19:06 +01:00
|
|
|
- sym_mode: {{ user_files_sym_mode }}
|
|
|
|
{% endif -%}
|
2018-06-21 17:01:01 +02:00
|
|
|
{% if user_files_exclude_pat -%}
|
2018-06-21 18:22:24 +02:00
|
|
|
- exclude_pat: "{{ user_files_exclude_pat }}"
|
2018-06-21 17:01:01 +02:00
|
|
|
{% endif -%}
|
2015-08-21 22:42:25 +02:00
|
|
|
- include_empty: True
|
|
|
|
- keep_symlinks: True
|
|
|
|
- require:
|
|
|
|
- user: users_{{ username }}_user
|
|
|
|
- file: users_{{ username }}_user
|
|
|
|
{% endif -%}
|
2015-08-21 22:52:36 +02:00
|
|
|
|
|
|
|
{%- endif -%}
|
|
|
|
{%- endfor -%}
|