Browse Source

New format of user.absent support introduced. Old format still supported.

tags/v0.45.0
Slawomir Pucia 10 years ago
parent
commit
07aeb2c4f8
2 changed files with 32 additions and 7 deletions
  1. +11
    -4
      pillar.example
  2. +21
    -3
      users/init.sls

+ 11
- 4
pillar.example View File

users: users:
## Minimal required pillar values
## Minimal required pillar values
auser: auser:
groups:
- admin
fullname: A User


## Full list of pillar values
## Full list of pillar values
buser: buser:
fullname: B User fullname: B User
home: /custom/buser home: /custom/buser
ssh_auth: ssh_auth:
- PUBLICKEY - PUBLICKEY


## Absent user
cuser:
absent: True
purge: True
force: True


## Old syntax of absent_users still supported
absent_users: absent_users:
- donald - donald
- bad_guy - bad_guy

+ 21
- 3
users/init.sls View File

include: include:
- users.sudo - users.sudo


{% for name, user in pillar.get('users', {}).items() %}
{% for name, user in pillar.get('users', {}).items() if user.absent is not defined or not user.absent %}
{%- if user == None -%} {%- if user == None -%}
{%- set user = {} -%} {%- set user = {} -%}
{%- endif -%} {%- endif -%}
{% endif %} {% endif %}




{% if 'ssh_auth' in user %}
{% for auth in user['ssh_auth'] %}
{% if 'ssh_auth' in user %}
{% for auth in user['ssh_auth'] %}
ssh_auth_{{ name }}_{{ loop.index0 }}: ssh_auth_{{ name }}_{{ loop.index0 }}:
ssh_auth.present: ssh_auth.present:
- user: {{ name }} - user: {{ name }}


{% endfor %} {% endfor %}


{% for name, user in pillar.get('users', {}).items() if user.absent is defined and user.absent %}
{{ name }}:
{% if 'purge' in user or 'force' in user %}
user.absent:
{% if 'purge' in user %}
- purge: {{ user['purge'] }}
{% endif %}
{% if 'force' in user %}
- force: {{ user['force'] }}
{% endif %}
{% else %}
user.absent
{% endif -%}
/etc/sudoers.d/{{ name }}:
file.absent:
- name: /etc/sudoers.d/{{ name }}
{% endfor %}

{% for user in pillar.get('absent_users', []) %} {% for user in pillar.get('absent_users', []) %}
{{ user }}: {{ user }}:
user.absent user.absent

Loading…
Cancel
Save