2019-04-24 05:03:27 -04:00
|
|
|
{%- 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 }}
|
2019-04-24 11:29:58 -04:00
|
|
|
config: {{ config|tojson }}
|
2019-04-24 05:03:27 -04:00
|
|
|
|
|
|
|
{% elif state == 'absent' %}
|
|
|
|
/etc/sudoers.d/{{ filename }}:
|
|
|
|
file.absent
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{%- endmacro %}
|