|
|
|
|
|
|
|
|
- users.sudo |
|
|
- users.sudo |
|
|
|
|
|
|
|
|
{% for name, user in pillar.get('users', {}).items() %} |
|
|
{% for name, user in pillar.get('users', {}).items() %} |
|
|
{% if user == None %} |
|
|
|
|
|
{% set user = {} %} |
|
|
|
|
|
{% endif %} |
|
|
|
|
|
{% set home = user.get('home', "/home/%s" % name) %} |
|
|
|
|
|
|
|
|
{%- if user == None -%} |
|
|
|
|
|
{%- set user = {} -%} |
|
|
|
|
|
{%- endif -%} |
|
|
|
|
|
{%- set home = user.get('home', "/home/%s" % name) -%} |
|
|
|
|
|
|
|
|
|
|
|
{%- if 'prime_group' in user and 'name' in user['prime_group'] %} |
|
|
|
|
|
{%- set user_group = user.prime_group.name -%} |
|
|
|
|
|
{%- else -%} |
|
|
|
|
|
{%- set user_group = name -%} |
|
|
|
|
|
{%- endif %} |
|
|
|
|
|
|
|
|
{% for group in user.get('groups', []) %} |
|
|
{% for group in user.get('groups', []) %} |
|
|
{{ group }}_group: |
|
|
{{ group }}_group: |
|
|
|
|
|
|
|
|
file.directory: |
|
|
file.directory: |
|
|
- name: {{ home }} |
|
|
- name: {{ home }} |
|
|
- user: {{ name }} |
|
|
- user: {{ name }} |
|
|
- group: {{ name }} |
|
|
|
|
|
|
|
|
- group: {{ user_group }} |
|
|
- mode: 0755 |
|
|
- mode: 0755 |
|
|
- require: |
|
|
- require: |
|
|
- user: {{ name }} |
|
|
- user: {{ name }} |
|
|
- group: {{ name }} |
|
|
|
|
|
|
|
|
- group: {{ user_group }} |
|
|
group.present: |
|
|
group.present: |
|
|
- name: {{ name }} |
|
|
|
|
|
{% if 'uid' in user -%} |
|
|
|
|
|
|
|
|
- name: {{ user_group }} |
|
|
|
|
|
{%- if 'prime_group' in user and 'gid' in user['prime_group'] %} |
|
|
|
|
|
- gid: {{ user['prime_group']['gid'] }} |
|
|
|
|
|
{%- elif 'uid' in user %} |
|
|
- gid: {{ user['uid'] }} |
|
|
- gid: {{ user['uid'] }} |
|
|
{% endif %} |
|
|
|
|
|
|
|
|
{%- endif %} |
|
|
user.present: |
|
|
user.present: |
|
|
- name: {{ name }} |
|
|
- name: {{ name }} |
|
|
- home: {{ home }} |
|
|
- home: {{ home }} |
|
|
- shell: {{ user.get('shell', '/bin/bash') }} |
|
|
- shell: {{ user.get('shell', '/bin/bash') }} |
|
|
{% if 'uid' in user -%} |
|
|
{% if 'uid' in user -%} |
|
|
- uid: {{ user['uid'] }} |
|
|
- uid: {{ user['uid'] }} |
|
|
{% endif %} |
|
|
|
|
|
|
|
|
{% endif -%} |
|
|
|
|
|
{% if 'prime_group' in user and 'gid' in user['prime_group'] -%} |
|
|
|
|
|
- gid: {{ user['prime_group']['gid'] }} |
|
|
|
|
|
{% else -%} |
|
|
- gid_from_name: True |
|
|
- gid_from_name: True |
|
|
|
|
|
{% endif -%} |
|
|
{% if 'fullname' in user %} |
|
|
{% if 'fullname' in user %} |
|
|
- fullname: {{ user['fullname'] }} |
|
|
- fullname: {{ user['fullname'] }} |
|
|
{% endif %} |
|
|
|
|
|
|
|
|
{% endif -%} |
|
|
- groups: |
|
|
- groups: |
|
|
- {{ name }} |
|
|
|
|
|
{% for group in user.get('groups', []) %} |
|
|
|
|
|
- {{ group }} |
|
|
|
|
|
|
|
|
- {{ user_group }} |
|
|
|
|
|
{% for group in user.get('groups', []) -%} |
|
|
|
|
|
- {{ group }} |
|
|
{% endfor %} |
|
|
{% endfor %} |
|
|
- require: |
|
|
- require: |
|
|
- group: {{ name }} |
|
|
|
|
|
{% for group in user.get('groups', []) %} |
|
|
|
|
|
- group: {{ group }} |
|
|
|
|
|
|
|
|
- group: {{ user_group }} |
|
|
|
|
|
{% for group in user.get('groups', []) -%} |
|
|
|
|
|
- group: {{ group }} |
|
|
{% endfor %} |
|
|
{% endfor %} |
|
|
|
|
|
|
|
|
user_keydir_{{ name }}: |
|
|
user_keydir_{{ name }}: |
|
|
file.directory: |
|
|
file.directory: |
|
|
- name: {{ user.get('home', '/home/{0}'.format(name)) }}/.ssh |
|
|
- name: {{ user.get('home', '/home/{0}'.format(name)) }}/.ssh |
|
|
- user: {{ name }} |
|
|
- user: {{ name }} |
|
|
- group: {{ name }} |
|
|
|
|
|
|
|
|
- group: {{ user_group }} |
|
|
- makedirs: True |
|
|
- makedirs: True |
|
|
- mode: 744 |
|
|
- mode: 744 |
|
|
- require: |
|
|
- require: |
|
|
- user: {{ name }} |
|
|
- user: {{ name }} |
|
|
- group: {{ name }} |
|
|
|
|
|
{% for group in user.get('groups', []) %} |
|
|
|
|
|
|
|
|
- group: {{ user_group }} |
|
|
|
|
|
{%- for group in user.get('groups', []) %} |
|
|
- group: {{ group }} |
|
|
- group: {{ group }} |
|
|
{% endfor %} |
|
|
|
|
|
|
|
|
{%- endfor %} |
|
|
|
|
|
|
|
|
{% if 'privkey' in user %} |
|
|
{% if 'privkey' in user %} |
|
|
user_{{ name }}_private_key: |
|
|
user_{{ name }}_private_key: |
|
|
file.managed: |
|
|
file.managed: |
|
|
- name: {{ user.get('home', '/home/{0}'.format(name)) }}/.ssh/id_rsa |
|
|
- name: {{ user.get('home', '/home/{0}'.format(name)) }}/.ssh/id_rsa |
|
|
- user: {{ name }} |
|
|
- user: {{ name }} |
|
|
- group: {{ name }} |
|
|
|
|
|
|
|
|
- group: {{ user_group }} |
|
|
- mode: 600 |
|
|
- mode: 600 |
|
|
- source: salt://keys/{{ user['privkey'] }} |
|
|
- source: salt://keys/{{ user['privkey'] }} |
|
|
- require: |
|
|
- require: |