Created
December 23, 2016 23:53
-
-
Save evilbulgarian/24a867288891fbb864465536a4ca0a7f to your computer and use it in GitHub Desktop.
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
{% for user in pillar['users'] %} | |
user_{{user.name}}: | |
group.present: | |
- name: {{user.name}} | |
- gid: {{user.gid}} | |
user.present: | |
- name: {{user.name}} | |
- fullname: {{user.fullname}} | |
- password: {{user.shadow}} | |
- shell: {{user.shell}} | |
- uid: {{user.uid}} | |
- gid: {{user.gid}} | |
{% if user.groups %} | |
- optional_groups: | |
{% for group in user.groups %} | |
- {{group}} | |
{% endfor %} | |
{% endif %} | |
- require: | |
- group: user_{{user.name}} | |
file.directory: | |
- name: /home/{{user.name}} | |
- user: {{user.name}} | |
- group: {{user.name}} | |
- mode: 0751 | |
- makedirs: True | |
user_{{user.name}}_forward: | |
file.append: | |
- name: /home/{{user.name}}/.forward | |
- text: {{user.email}} | |
user_{{user.name}}_sshdir: | |
file.directory: | |
- name: /home/{{user.name}}/.ssh | |
- user: {{user.name}} | |
- group: {{user.name}} | |
- mode: 0700 | |
{% if 'authkey' in user %} | |
user_{{user.name}}_authkeys: | |
ssh_auth.present: | |
- user: {{user.name}} | |
- name: {{user.authkey}} | |
{% endif %} | |
{% if 'sshpriv' in user %} | |
user_{{user.name}}_sshpriv: | |
file.managed: | |
- name: /home/{{user.name}}/.ssh/id_rsa | |
- user: {{user.name}} | |
- group: {{user.name}} | |
- mode: 0600 | |
- contents_pillar: {{user.sshpriv}} | |
{% endif %} | |
{% if 'sshpub' in user %} | |
user_{{user.name}}_sshpub: | |
file.managed: | |
- name: /home/{{user.name}}/.ssh/id_rsa.pub | |
- user: {{user.name}} | |
- group: {{user.name}} | |
- mode: 0600 | |
- contents_pillar: {{user.sshpub}} | |
{% endif %} | |
{% endfor %} # user in users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment