|
|
|
|
|
|
|
|
|
|
|
# vim: sts=2 ts=2 sw=2 et ai |
|
|
|
|
|
{% from "users/map.jinja" import users with context %} |
|
|
|
|
|
|
|
|
include: |
|
|
include: |
|
|
- users.sudo |
|
|
- users.sudo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% if 'sudouser' in user and user['sudouser'] %} |
|
|
{% if 'sudouser' in user and user['sudouser'] %} |
|
|
sudoer-{{ name }}: |
|
|
sudoer-{{ name }}: |
|
|
file.managed: |
|
|
file.managed: |
|
|
- name: /etc/sudoers.d/{{ name }} |
|
|
|
|
|
|
|
|
- name: {{ users.sudoers_dir }}{{ name }} |
|
|
- user: root |
|
|
- user: root |
|
|
- group: root |
|
|
|
|
|
|
|
|
- group: {{ users.root_group }} |
|
|
- mode: '0440' |
|
|
- mode: '0440' |
|
|
{% if 'sudo_rules' in user %} |
|
|
{% if 'sudo_rules' in user %} |
|
|
{% for rule in user['sudo_rules'] %} |
|
|
{% for rule in user['sudo_rules'] %} |
|
|
"validate {{ name }} sudo rule {{ loop.index0 }} {{ name }} {{ rule }}": |
|
|
"validate {{ name }} sudo rule {{ loop.index0 }} {{ name }} {{ rule }}": |
|
|
cmd.run: |
|
|
cmd.run: |
|
|
- name: 'visudo -cf - <<<"$rule"' |
|
|
- name: 'visudo -cf - <<<"$rule"' |
|
|
- shell: /bin/bash |
|
|
|
|
|
|
|
|
- shell: {{ users.visudo_shell }} |
|
|
- env: |
|
|
- env: |
|
|
# Specify the rule via an env var to avoid shell quoting issues. |
|
|
# Specify the rule via an env var to avoid shell quoting issues. |
|
|
- rule: "{{ name }} {{ rule }}" |
|
|
- rule: "{{ name }} {{ rule }}" |
|
|
- require_in: |
|
|
- require_in: |
|
|
- file: /etc/sudoers.d/{{ name }} |
|
|
|
|
|
|
|
|
- file: {{ users.sudoers_dir }}{{ name }} |
|
|
{% endfor %} |
|
|
{% endfor %} |
|
|
|
|
|
|
|
|
/etc/sudoers.d/{{ name }}: |
|
|
|
|
|
|
|
|
{{ users.sudoers_dir }}{{ name }}: |
|
|
file.managed: |
|
|
file.managed: |
|
|
- contents: | |
|
|
- contents: | |
|
|
{%- for rule in user['sudo_rules'] %} |
|
|
{%- for rule in user['sudo_rules'] %} |
|
|
|
|
|
|
|
|
- file: sudoer-{{ name }} |
|
|
- file: sudoer-{{ name }} |
|
|
{% endif %} |
|
|
{% endif %} |
|
|
{% else %} |
|
|
{% else %} |
|
|
/etc/sudoers.d/{{ name }}: |
|
|
|
|
|
|
|
|
{{ users.sudoers_dir }}{{ name }}: |
|
|
file.absent: |
|
|
file.absent: |
|
|
- name: /etc/sudoers.d/{{ name }} |
|
|
|
|
|
|
|
|
- name: {{ users.sudoers_dir }}{{ name }} |
|
|
{% endif %} |
|
|
{% endif %} |
|
|
|
|
|
|
|
|
{% endfor %} |
|
|
{% endfor %} |
|
|
|
|
|
|
|
|
{% else %} |
|
|
{% else %} |
|
|
user.absent |
|
|
user.absent |
|
|
{% endif -%} |
|
|
{% endif -%} |
|
|
/etc/sudoers.d/{{ name }}: |
|
|
|
|
|
|
|
|
{{ users.sudoers_dir }}{{ name }}: |
|
|
file.absent: |
|
|
file.absent: |
|
|
- name: /etc/sudoers.d/{{ name }} |
|
|
|
|
|
|
|
|
- name: {{ users.sudoers_dir }}{{ name }} |
|
|
{% endfor %} |
|
|
{% endfor %} |
|
|
|
|
|
|
|
|
{% for user in pillar.get('absent_users', []) %} |
|
|
{% for user in pillar.get('absent_users', []) %} |
|
|
{{ user }}: |
|
|
{{ user }}: |
|
|
user.absent |
|
|
user.absent |
|
|
/etc/sudoers.d/{{ user }}: |
|
|
|
|
|
|
|
|
{{ users.sudoers_dir }}{{ user }}: |
|
|
file.absent: |
|
|
file.absent: |
|
|
- name: /etc/sudoers.d/{{ user }} |
|
|
|
|
|
|
|
|
- name: {{ users.sudoers_dir }}{{ user }} |
|
|
{% endfor %} |
|
|
{% endfor %} |
|
|
|
|
|
|
|
|
{% for group in pillar.get('absent_groups', []) %} |
|
|
{% for group in pillar.get('absent_groups', []) %} |