Stanislav Asunkin pirms 1 gada
vecāks
revīzija
6e87db4afa
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 40 papildinājumiem un 22 dzēšanām
  1. +40
    -22
      users/init.sls

+ 40
- 22
users/init.sls Parādīt failu

@@ -4,6 +4,8 @@
{% set used_googleauth = [] %}
{% set used_user_files = [] %}
{% set used_polkit = [] %}
{%- set create_dirs = [] %}
{%- set created_groups = [] %}

{% for group, setting in salt['pillar.get']('groups', {}).items() %}
{% if setting.absent is defined and setting.absent or setting.get('state', "present") == 'absent' %}
@@ -11,6 +13,7 @@ users_group_absent_{{ group }}:
group.absent:
- name: {{ group }}
{% else %}
{%- do created_groups.append(group) %}
users_group_present_{{ group }}:
group.present:
- name: {{ group }}
@@ -75,9 +78,33 @@ include:
{%- set user_group = name -%}
{%- endif %}

{%- if createhome %}
{%- set required_dir = salt['file.dirname'](home) %}
{%- do create_dirs.append(required_dir) %}
{%- endif %}

{%- if not ( 'sudoonly' in user and user['sudoonly'] ) %}
{% for group in user.get('groups', []) %}
users_{{ name }}_{{ group }}_group:

{#- create prime group #}
{%- if user_group not in created_groups %}
{%- do created_groups.append(user_group) %}
users_group_present_{{ user_group }}:
group.present:
- 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'] }}
{%- endif %}
{% if 'system' in user and user['system'] %}
- system: True
{% endif %}
{%- endif %}

{#- create required groups #}
{%- for group in user.get('groups', []) if group not in created_groups %}
{%- do created_groups.append(group) %}
users_group_present_{{ group }}:
group.present:
- name: {{ group }}
{% if group == 'sudo' %}
@@ -85,16 +112,6 @@ users_{{ name }}_{{ group }}_group:
{% endif %}
{% endfor %}

{# in case home subfolder doesn't exist, create it before the user exists #}
{% if createhome -%}
users_{{ name }}_user_prereq:
file.directory:
- name: {{ salt['file.dirname'](home) }}
- makedirs: True
- prereq:
- user: users_{{ name }}_user
{%- endif %}

users_{{ name }}_user:
{% if createhome -%}
file.directory:
@@ -107,16 +124,6 @@ users_{{ name }}_user:
- user: users_{{ name }}_user
- group: {{ user_group }}
{%- endif %}
group.present:
- 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'] }}
{%- endif %}
{% if 'system' in user and user['system'] %}
- system: True
{% endif %}
user.present:
- name: {{ name }}
- home: {{ home }}
@@ -207,6 +214,9 @@ users_{{ name }}_user:
{% for group in user.get('groups', []) -%}
- group: {{ group }}
{% endfor %}
{%- if createhome and required_dir != '/' %}
- file: users_prereq_dir_{{ required_dir }}
{%- endif %}


{% if 'ssh_keys' in user or
@@ -568,6 +578,14 @@ users_{{ name }}_user_gitconfig_absent_{{ key }}:

{% endfor %}

{#- create directories for homes #}
{%- for dir in create_dirs|unique|reject('equalto', '/') %}
users_prereq_dir_{{ dir }}:
file.directory:
- name: {{ dir }}
- makedirs: True
{%- endfor %}


{% for name, user in pillar.get('users', {}).items()
if user.absent is defined and user.absent %}

Notiek ielāde…
Atcelt
Saglabāt