瀏覽代碼

Merge pull request #103 from salt-formulas/users_deps

Fix requirements on groups and users
feature/network_systemd
Filip Pytloun 7 年之前
父節點
當前提交
e5ecffc87c
共有 4 個文件被更改,包括 20 次插入5 次删除
  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 查看文件

@@ -7,7 +7,7 @@

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

+ 4
- 0
linux/system/job.sls 查看文件

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

+ 9
- 0
linux/system/user.sls 查看文件

@@ -5,6 +5,14 @@

{%- 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 }}:
user.present:
- name: {{ name }}
@@ -25,6 +33,7 @@ system_user_{{ name }}:
{%- if user.uid is defined and user.uid %}
- uid: {{ user.uid }}
{%- endif %}
- require: {{ requires|yaml }}

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

+ 6
- 4
tests/pillar/system.sls 查看文件

@@ -43,7 +43,8 @@ linux:
full_name: Test User
home: /home/test
groups:
- root
- db-ops
- salt-ops
salt_user1:
enabled: true
name: saltuser1
@@ -58,18 +59,19 @@ linux:
uid: 9992
full_name: Salt Sudo User2
home: /home/saltuser2
groups:
- sudogroup1
group:
testgroup:
test:
enabled: true
name: test
gid: 9999
system: true
db-ops:
enabled: true
name: testgroup
salt-ops:
enabled: true
name: sudogroup0
name: salt-ops
sudogroup1:
enabled: true
name: sudogroup1

Loading…
取消
儲存