0
0
mirror of https://github.com/saltstack-formulas/sudoers-formula.git synced 2024-11-30 21:45:34 +01:00
sudoers-formula/sudoers/macros.sls
Anthony Martinet d8a0e12abf fix(macros)
2019-04-24 17:29:58 +02:00

23 lines
565 B
Plaintext

{%- macro sudoers(for_user, sudo, config, priority='20', state='present') -%}
{%- set filename = priority ~ '-' ~ for_user|replace('.','-') ~ '-' ~ sudo %}
{% if state == 'present' %}
/etc/sudoers.d/{{ filename }}:
file.managed:
- user: root
- group: root
- mode: 440
- template: jinja
- source: salt://sudoers/templates/sudoers.jinja
- context:
for_user: {{ for_user }}
sudo: {{ sudo }}
config: {{ config|tojson }}
{% elif state == 'absent' %}
/etc/sudoers.d/{{ filename }}:
file.absent
{% endif %}
{%- endmacro %}