From 6ed440b66a7bf8285598b0c3702c76db7391a842 Mon Sep 17 00:00:00 2001 From: Jessy Date: Mon, 14 Jan 2019 14:48:04 +0100 Subject: [PATCH 1/3] reworked "createhome" (variable, passwd entry & issue #164) --- users/init.sls | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/users/init.sls b/users/init.sls index 844cfd8..ee06d21 100644 --- a/users/init.sls +++ b/users/init.sls @@ -53,6 +53,7 @@ include: {%- endif -%} {%- set current = salt.user.info(name) -%} {%- set home = user.get('home', current.get('home', "/home/%s" % name)) -%} +{%- set createhome = user.get('createhome', True) -%} {%- if 'prime_group' in user and 'name' in user['prime_group'] %} {%- set user_group = user.prime_group.name -%} @@ -71,7 +72,7 @@ users_{{ name }}_{{ group }}_group: {% endfor %} {# in case home subfolder doesn't exist, create it before the user exists #} -{% if user.get('createhome', True) %} +{% if createhome -%} users_{{ name }}_user_prereq: file.directory: - name: {{ salt['file.dirname'](home) }} @@ -81,7 +82,7 @@ users_{{ name }}_user_prereq: {%- endif %} users_{{ name }}_user: - {% if user.get('createhome', True) %} + {% if createhome -%} file.directory: - name: {{ home }} - user: {{ user.get('homedir_owner', name) }} @@ -104,9 +105,7 @@ users_{{ name }}_user: {% endif %} user.present: - name: {{ name }} - {% if user.get('createhome', True) -%} - home: {{ home }} - {% endif -%} - shell: {{ user.get('shell', current.get('shell', users.get('shell', '/bin/bash'))) }} {% if 'uid' in user -%} - uid: {{ user['uid'] }} @@ -145,7 +144,7 @@ users_{{ name }}_user: {% if 'homephone' in user %} - homephone: {{ user['homephone'] }} {% endif %} - {% if not user.get('createhome', True) %} + {% if not createhome -%} - createhome: False {% endif %} {% if not user.get('unique', True) %} @@ -325,7 +324,9 @@ users_ssh_auth_source_{{ name }}_{{ loop.index0 }}: - user: {{ name }} - source: {{ pubkey_file }} - require: + {% if createhome -%} - file: users_{{ name }}_user + {% endif -%} - user: users_{{ name }}_user {% endfor %} {% endif %} @@ -337,7 +338,9 @@ users_ssh_auth_source_delete_{{ name }}_{{ loop.index0 }}: - user: {{ name }} - source: {{ pubkey_file }} - require: + {% if createhome -%} - file: users_{{ name }}_user + {% endif -%} - user: users_{{ name }}_user {% endfor %} {% endif %} @@ -349,7 +352,9 @@ users_ssh_auth_delete_{{ name }}_{{ loop.index0 }}: - user: {{ name }} - name: {{ auth }} - require: + {% if createhome -%} - file: users_{{ name }}_user + {% endif -%} - user: users_{{ name }}_user {% endfor %} {% endif %} From fd25c3e4a444dd8133e14011b6309d8a7ccb13a9 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 17 Jan 2019 13:32:08 +0100 Subject: [PATCH 2/3] incorporated change suggestions --- users/defaults.yaml | 1 + users/init.sls | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/users/defaults.yaml b/users/defaults.yaml index 09a0dd9..2b69c19 100644 --- a/users/defaults.yaml +++ b/users/defaults.yaml @@ -6,4 +6,5 @@ users-formula: users: allow_gid_change: True + createhome: True diff --git a/users/init.sls b/users/init.sls index ee06d21..696ccbd 100644 --- a/users/init.sls +++ b/users/init.sls @@ -53,7 +53,7 @@ include: {%- endif -%} {%- set current = salt.user.info(name) -%} {%- set home = user.get('home', current.get('home', "/home/%s" % name)) -%} -{%- set createhome = user.get('createhome', True) -%} +{%- set createhome = user.get('createhome') -%} {%- if 'prime_group' in user and 'name' in user['prime_group'] %} {%- set user_group = user.prime_group.name -%} @@ -144,9 +144,7 @@ users_{{ name }}_user: {% if 'homephone' in user %} - homephone: {{ user['homephone'] }} {% endif %} - {% if not createhome -%} - - createhome: False - {% endif %} + - createhome: {{ createhome }} {% if not user.get('unique', True) %} - unique: False {% endif %} From 634deacc73081f282736707af22fb53cfee30cbe Mon Sep 17 00:00:00 2001 From: Jessy Date: Thu, 17 Jan 2019 13:36:01 +0100 Subject: [PATCH 3/3] incorporated change suggestions --- users/defaults.yaml | 1 + users/init.sls | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/users/defaults.yaml b/users/defaults.yaml index 09a0dd9..2b69c19 100644 --- a/users/defaults.yaml +++ b/users/defaults.yaml @@ -6,4 +6,5 @@ users-formula: users: allow_gid_change: True + createhome: True diff --git a/users/init.sls b/users/init.sls index ee06d21..696ccbd 100644 --- a/users/init.sls +++ b/users/init.sls @@ -53,7 +53,7 @@ include: {%- endif -%} {%- set current = salt.user.info(name) -%} {%- set home = user.get('home', current.get('home', "/home/%s" % name)) -%} -{%- set createhome = user.get('createhome', True) -%} +{%- set createhome = user.get('createhome') -%} {%- if 'prime_group' in user and 'name' in user['prime_group'] %} {%- set user_group = user.prime_group.name -%} @@ -144,9 +144,7 @@ users_{{ name }}_user: {% if 'homephone' in user %} - homephone: {{ user['homephone'] }} {% endif %} - {% if not createhome -%} - - createhome: False - {% endif %} + - createhome: {{ createhome }} {% if not user.get('unique', True) %} - unique: False {% endif %}