1
0
Fork 0
mirror of synced 2024-11-15 13:48:58 -05:00
formula-sudoers/sudoers/included.sls
Sebastian Meyer 73d2d70dbb
Make management of the main sudoers config optional
It should be possible to not overwrite the main sudoers configuration
file and only provide files to be included. This introduces a new Pillar
variable to achieve that. If it's not set we default to the old
behaviour of managing that file.
2018-08-22 12:30:32 +02:00

30 lines
982 B
Text

{% from "sudoers/map.jinja" import sudoers with context %}
include:
- sudoers
{% do sudoers.update(pillar.get('sudoers', {})) %}
{% set includedir = sudoers.get('includedir', '/etc/sudoers.d') %}
{% set included_files = sudoers.get('included_files', {}) %}
{% for included_file,spec in included_files.items() -%}
sudoers include {{ included_file }}:
file.managed:
{% if '/' in included_file %}
- name: {{ included_file }}
{% else %}
- name: {{ includedir }}/{{ included_file }}
{% endif %}
- user: root
- group: {{ sudoers.get('group', 'root') }}
- mode: 440
- template: jinja
- source: salt://sudoers/files/sudoers
- check_cmd: {{ sudoers.get('execprefix', '/usr/sbin') }}/visudo -c -f
- context:
included: True
sudoers: {{ spec|json }}
{% if salt['pillar.get']('sudoers:manage_main_config', True) %}
- require:
- file: {{ sudoers.get('configpath', '/etc') }}/sudoers
{% endif %}
{% endfor %}