Created
January 28, 2018 09:24
-
-
Save leogaggl/9198889ea9d78c03b9cbe976d08bec84 to your computer and use it in GitHub Desktop.
User state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# loop over all users presented by pillar: | |
# create user's group, create user, then add pub keys | |
{% for username, details in pillar.get('users', {}).items() %} | |
{{ username }}: | |
group: | |
- present | |
- name: {{ username }} | |
- gid: {{ details.get('gid', '') }} | |
user: | |
- present | |
- fullname: {{ details.get('fullname','') }} | |
- name: {{ username }} | |
- shell: {{ details.get('shell', '') }} | |
- home: /home/{{ username }} | |
- createhome: True | |
- uid: {{ details.get('uid', '') }} | |
- gid: {{ details.get('gid', '') }} | |
- password: {{ details.get('crypt','') }} | |
{% if 'groups' in details %} | |
- groups: | |
{% for group in details.get('groups', []) %} | |
- {{ group }} | |
{% endfor %} | |
- require: | |
{% for group in details.get('groups', []) %} | |
- group: {{ group }} | |
{% endfor %} | |
{% endif %} | |
{% if 'pub_ssh_keys' in details %} | |
ssh_auth: | |
- present | |
- user: {{ username }} | |
- names: | |
{% for pub_ssh_key in details.get('pub_ssh_keys', []) %} | |
- {{ pub_ssh_key }} | |
{% endfor %} | |
- require: | |
- user: {{ username }} | |
{% endif %} | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment