2020-08-24 11:26:54 -04:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: ft=sls
|
|
|
|
|
|
|
|
{#- Get the `tplroot` from `tpldir` #}
|
|
|
|
{%- set tplroot = tpldir.split('/')[0] %}
|
|
|
|
{%- set sls_config_file = tplroot ~ '.config.file' %}
|
|
|
|
{%- from tplroot ~ "/map.jinja" import sudoers with context %}
|
2014-10-02 03:29:40 -04:00
|
|
|
|
2014-02-09 12:32:22 -05:00
|
|
|
include:
|
|
|
|
- sudoers
|
|
|
|
|
2020-08-24 11:58:35 -04:00
|
|
|
{{ sudoers.includedir }}:
|
|
|
|
file.directory:
|
|
|
|
- user: root
|
|
|
|
- group: {{ sudoers.group }}
|
2020-11-24 22:30:47 -05:00
|
|
|
- mode: 750
|
2020-08-24 11:58:35 -04:00
|
|
|
- clean: {{ sudoers.purge_includedir }}
|
|
|
|
|
2020-08-24 11:26:54 -04:00
|
|
|
{% set included_files = sudoers.included_files %}
|
|
|
|
{% 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 %}
|
2020-08-24 11:26:54 -04:00
|
|
|
- name: {{ sudoers.includedir }}/{{ included_file }}
|
2018-02-04 14:04:11 -05:00
|
|
|
{% endif %}
|
2014-02-09 12:32:22 -05:00
|
|
|
- user: root
|
2020-08-24 11:26:54 -04:00
|
|
|
- group: {{ sudoers.group }}
|
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
|
2020-08-24 11:26:54 -04:00
|
|
|
- check_cmd: {{ sudoers.execprefix }}/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 }}
|
2020-08-24 11:26:54 -04:00
|
|
|
{% if sudoers.manage_main_config %}
|
2014-02-09 12:32:22 -05:00
|
|
|
- require:
|
2020-08-24 11:26:54 -04:00
|
|
|
- file: {{ sudoers.configpath }}/sudoers
|
2021-02-20 13:14:26 -05:00
|
|
|
- require_in:
|
|
|
|
- file: {{ sudoers.includedir }}
|
2021-08-18 19:05:27 -04:00
|
|
|
{% elif sudoers.append_included_files_to_endof_main_config %}
|
|
|
|
file.append:
|
|
|
|
- name: {{ sudoers.configpath }}/sudoers
|
|
|
|
- text: '#include {{ sudoers.configpath }}/sudoers.d/{{ included_file }}'
|
2018-08-22 06:14:02 -04:00
|
|
|
{% endif %}
|
2014-02-09 12:32:22 -05:00
|
|
|
{% endfor %}
|