Skips user if it's enabled without a specified source, and their directory does not exist.
This commit is contained in:
parent
cdb862e968
commit
b986e1e7f2
@ -15,7 +15,7 @@
|
|||||||
{%- if 'google_auth' in user %}
|
{%- if 'google_auth' in user %}
|
||||||
{%- do used_googleauth.append(1) %}
|
{%- do used_googleauth.append(1) %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if pillar.get('users:' + name + ':user_files:enabled', False) %}
|
{%- if salt['pillar.get']('users:' ~ name ~ ':user_files:enabled', False) %}
|
||||||
{%- do used_user_files.append(1) %}
|
{%- do used_user_files.append(1) %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -3,22 +3,29 @@
|
|||||||
include:
|
include:
|
||||||
- users
|
- users
|
||||||
|
|
||||||
{%- for username, user in pillar.get('users', {}).items() if (user.absent is not defined or not user.absent) -%}
|
{% set userfile_dirs = salt['cp.list_master_dirs'](prefix='users/files/user/') -%}
|
||||||
{%- set user_files = pillar.get('users:' + username + ':user_files', {'enabled': False}) -%}
|
{%- for username, user in salt['pillar.get']('users', {}).items() if (user.absent is not defined or not user.absent) -%}
|
||||||
|
{%- set user_files = salt['pillar.get'](('users:' ~ username ~ ':user_files'), {'enabled': False}) -%}
|
||||||
|
{%- set user_group = salt['pillar.get'](('users:' ~ username ~ ':prime_group:name'), username) -%}
|
||||||
{%- if user_files.enabled -%}
|
{%- if user_files.enabled -%}
|
||||||
{%- set user_group = pillar.get(('users:' + username + ':prime_group:name'), username) -%}
|
|
||||||
|
|
||||||
{%- if user_files.source is defined -%}
|
{%- if user_files.source is defined -%}
|
||||||
{%- if user_files.source.startswith('salt://') -%}
|
{%- if user_files.source.startswith('salt://') -%}
|
||||||
{%- set file_source = user_files.source -%}
|
{%- set file_source = user_files.source -%}
|
||||||
|
{%- else -%}
|
||||||
|
{%- set file_source = ('salt://' ~ user.user_files.source) -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- set skip_user = False -%}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- set file_source = ('salt://' + user.user_files.source) -%}
|
{%- if ('users/files/user/' ~ username) in userfile_dirs -%}
|
||||||
{%- endif -%}
|
{%- set file_source = ('salt://users/files/user/' ~ username) -%}
|
||||||
{%- else -%}
|
{%- set skip_user = False -%}
|
||||||
{%- set file_source = ('salt://users/files/user/' + username) -%}
|
{%- else -%}
|
||||||
|
{%- set skip_user = True -%}
|
||||||
|
{%- endif -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
|
{%- if not skip_user %}
|
||||||
users_userfiles_{{ username }}_recursive:
|
users_userfiles_{{ username }}_recursive:
|
||||||
file.recurse:
|
file.recurse:
|
||||||
- name: {{ user.home }}
|
- name: {{ user.home }}
|
||||||
@ -31,6 +38,7 @@ users_userfiles_{{ username }}_recursive:
|
|||||||
- require:
|
- require:
|
||||||
- user: users_{{ username }}_user
|
- user: users_{{ username }}_user
|
||||||
- file: users_{{ username }}_user
|
- file: users_{{ username }}_user
|
||||||
|
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% endfor -%}
|
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
Loading…
Reference in New Issue
Block a user