mirror of
https://github.com/saltstack-formulas/users-formula.git
synced 2024-11-28 00:48:22 +01:00
possibility to define user-specific Defaults
This commit is contained in:
parent
d11e7046ec
commit
1546e2d186
@ -14,6 +14,8 @@ users:
|
|||||||
sudo_rules:
|
sudo_rules:
|
||||||
- ALL=(root) /usr/bin/find
|
- ALL=(root) /usr/bin/find
|
||||||
- ALL=(otheruser) /usr/bin/script.sh
|
- ALL=(otheruser) /usr/bin/script.sh
|
||||||
|
sudo_defaults:
|
||||||
|
- !requiretty
|
||||||
shell: /bin/bash
|
shell: /bin/bash
|
||||||
prime_group:
|
prime_group:
|
||||||
name: primarygroup
|
name: primarygroup
|
||||||
|
@ -198,6 +198,7 @@ sudoer-{{ name }}:
|
|||||||
- user: root
|
- user: root
|
||||||
- group: {{ users.root_group }}
|
- group: {{ users.root_group }}
|
||||||
- mode: '0440'
|
- mode: '0440'
|
||||||
|
{% if 'sudo_rules' in user or 'sudo_defaults' in user %}
|
||||||
{% 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 }}":
|
||||||
@ -211,13 +212,35 @@ sudoer-{{ name }}:
|
|||||||
- require_in:
|
- require_in:
|
||||||
- file: {{ users.sudoers_dir }}/{{ name }}
|
- file: {{ users.sudoers_dir }}/{{ name }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if 'sudo_defaults' in user %}
|
||||||
|
{% for entry in user['sudo_defaults'] %}
|
||||||
|
"validate {{ name }} sudo Defaults {{ loop.index0 }} {{ name }} {{ entry }}":
|
||||||
|
cmd.run:
|
||||||
|
- name: 'visudo -cf - <<<"$rule" | { read output; if [[ $output != "stdin: parsed OK" ]] ; then echo $output ; fi }'
|
||||||
|
- stateful: True
|
||||||
|
- shell: {{ users.visudo_shell }}
|
||||||
|
- env:
|
||||||
|
# Specify the rule via an env var to avoid shell quoting issues.
|
||||||
|
- rule: "Defaults:{{ name }} {{ entry }}"
|
||||||
|
- require_in:
|
||||||
|
- file: {{ users.sudoers_dir }}/{{ name }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ users.sudoers_dir }}/{{ name }}:
|
{{ users.sudoers_dir }}/{{ name }}:
|
||||||
file.managed:
|
file.managed:
|
||||||
- contents: |
|
- contents: |
|
||||||
|
{%- if 'sudo_defaults' in user %}
|
||||||
|
{%- for entry in user['sudo_defaults'] %}
|
||||||
|
Defaults:{{ name }} {{ entry }}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- if 'sudo_rules' in user %}
|
||||||
{%- for rule in user['sudo_rules'] %}
|
{%- for rule in user['sudo_rules'] %}
|
||||||
{{ name }} {{ rule }}
|
{{ name }} {{ rule }}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
{%- endif %}
|
||||||
- require:
|
- require:
|
||||||
- file: sudoer-defaults
|
- file: sudoer-defaults
|
||||||
- file: sudoer-{{ name }}
|
- file: sudoer-{{ name }}
|
||||||
|
Loading…
Reference in New Issue
Block a user