Browse Source

Fix requirements on groups and users

Change-Id: I9767e07ffe3a808ee9a2de925862ba193b7b612e
users_deps
Filip Pytloun 7 years ago
parent
commit
d281d292b0
4 changed files with 20 additions and 5 deletions
  1. +1
    -1
      linux/system/group.sls
  2. +4
    -0
      linux/system/job.sls
  3. +9
    -0
      linux/system/user.sls
  4. +6
    -4
      tests/pillar/system.sls

+ 1
- 1
linux/system/group.sls View File



system_group_{{ group_name }}: system_group_{{ group_name }}:
group.present: group.present:
- name: {{ group.name }}
- name: {{ group.get('name', group_name) }}
{%- if group.system is defined and group.system %} {%- if group.system is defined and group.system %}
- system: True - system: True
{%- endif %} {%- endif %}

+ 4
- 0
linux/system/job.sls View File

{%- if job.dayweek is defined %} {%- if job.dayweek is defined %}
- dayweek: '{{ job.dayweek }}' - dayweek: '{{ job.dayweek }}'
{%- endif %} {%- endif %}
{%- if job.user in system.get('user', {}).keys() %}
- require:
- user: system_user_{{ job.user }}
{%- endif %}
{%- else %} {%- else %}
cron.absent: cron.absent:
- name: {{ job.command }} - name: {{ job.command }}

+ 9
- 0
linux/system/user.sls View File



{%- if user.enabled %} {%- if user.enabled %}


{%- set requires = [] %}
{%- for group in user.get('groups', []) %}
{%- if group in system.get('group', {}).keys() %}
{%- do requires.append({'group': 'system_group_'+group}) %}
{%- endif %}
{%- endfor %}


system_user_{{ name }}: system_user_{{ name }}:
user.present: user.present:
- name: {{ name }} - name: {{ name }}
{%- if user.uid is defined and user.uid %} {%- if user.uid is defined and user.uid %}
- uid: {{ user.uid }} - uid: {{ user.uid }}
{%- endif %} {%- endif %}
- require: {{ requires|yaml }}


system_user_home_{{ user.home }}: system_user_home_{{ user.home }}:
file.directory: file.directory:

+ 6
- 4
tests/pillar/system.sls View File

full_name: Test User full_name: Test User
home: /home/test home: /home/test
groups: groups:
- root
- db-ops
- salt-ops
salt_user1: salt_user1:
enabled: true enabled: true
name: saltuser1 name: saltuser1
uid: 9992 uid: 9992
full_name: Salt Sudo User2 full_name: Salt Sudo User2
home: /home/saltuser2 home: /home/saltuser2
groups:
- sudogroup1
group: group:
testgroup:
test:
enabled: true enabled: true
name: test name: test
gid: 9999 gid: 9999
system: true system: true
db-ops: db-ops:
enabled: true enabled: true
name: testgroup
salt-ops: salt-ops:
enabled: true enabled: true
name: sudogroup0
name: salt-ops
sudogroup1: sudogroup1:
enabled: true enabled: true
name: sudogroup1 name: sudogroup1

Loading…
Cancel
Save