Skip to content

Instantly share code, notes, and snippets.

Created May 6, 2015 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/adde3ff46ce9052c56b5 to your computer and use it in GitHub Desktop.
Save anonymous/adde3ff46ce9052c56b5 to your computer and use it in GitHub Desktop.
{% for user, args in pillar['users'].items() %}
{% if args['disabled'] is not defined %}
group_{{ user }}:
group.present:
- name: {{ user }}
{% if args['uid'] is defined -%}
- gid: {{ args['uid'] }}
{% endif %}
user_{{ user }}:
user.present:
- name: {{ user }}
{% if args['uid'] is defined -%}
- uid: {{ args['uid'] }}
{% endif -%}
- gid_from_name: True
{% if args['password'] is defined -%}
- password: {{ args['password'] }}
{% endif %}
{% if args['groups'] is defined -%}
- groups:
{% for group in args['groups'] -%}
- {{ group }}
{% endfor %}
{% endif %}
{% if args['key'] is defined %}
ssh_key_{{ user }}:
ssh_auth.present:
- name: {{ args['key'] }}
- user: {{ user }}
{% endif %}
{% else %}
user_{{ user }}:
user.absent:
- name: {{ user }}
{% if args['disabled']|lower() == 'purge' -%}
- purge: True
{% endif %}
group_{{ user }}:
group.absent:
- name: {{ user }}
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment