2015-01-01 17:14:56 -05:00
|
|
|
{% from "sudoers/map.jinja" import sudoers with context %}
|
2014-10-02 03:29:40 -04:00
|
|
|
|
2014-02-09 12:32:22 -05:00
|
|
|
include:
|
|
|
|
- sudoers
|
|
|
|
|
2015-01-10 17:48:19 -05:00
|
|
|
{% do sudoers.update(pillar.get('sudoers', {})) %}
|
2018-02-04 14:04:11 -05:00
|
|
|
{% set includedir = sudoers.get('includedir', '/etc/sudoers.d') %}
|
2014-12-24 09:08:03 -05:00
|
|
|
{% set included_files = sudoers.get('included_files', {}) %}
|
2014-02-09 12:32:22 -05:00
|
|
|
{% for included_file,spec in included_files.items() -%}
|
2018-02-04 14:04:11 -05:00
|
|
|
sudoers include {{ included_file }}:
|
2014-02-09 12:32:22 -05:00
|
|
|
file.managed:
|
2018-02-04 14:04:11 -05:00
|
|
|
{% if '/' in included_file %}
|
|
|
|
- name: {{ included_file }}
|
|
|
|
{% else %}
|
|
|
|
- name: {{ includedir }}/{{ included_file }}
|
|
|
|
{% endif %}
|
2014-02-09 12:32:22 -05:00
|
|
|
- user: root
|
2015-01-01 17:14:56 -05:00
|
|
|
- group: {{ sudoers.get('group', 'root') }}
|
2014-02-09 12:32:22 -05:00
|
|
|
- mode: 440
|
2018-11-06 16:18:05 -05:00
|
|
|
- makedirs: True
|
2014-02-09 12:32:22 -05:00
|
|
|
- template: jinja
|
|
|
|
- source: salt://sudoers/files/sudoers
|
2017-08-16 10:52:38 -04:00
|
|
|
- check_cmd: {{ sudoers.get('execprefix', '/usr/sbin') }}/visudo -c -f
|
2014-02-09 12:32:22 -05:00
|
|
|
- context:
|
|
|
|
included: True
|
2015-01-09 10:14:09 -05:00
|
|
|
sudoers: {{ spec|json }}
|
2018-08-22 06:14:02 -04:00
|
|
|
{% if salt['pillar.get']('sudoers:manage_main_config', True) %}
|
2014-02-09 12:32:22 -05:00
|
|
|
- require:
|
2017-08-16 08:32:42 -04:00
|
|
|
- file: {{ sudoers.get('configpath', '/etc') }}/sudoers
|
2018-08-22 06:14:02 -04:00
|
|
|
{% endif %}
|
2014-02-09 12:32:22 -05:00
|
|
|
{% endfor %}
|