mirror of
https://github.com/saltstack-formulas/sudoers-formula.git
synced 2026-09-24 13:13:44 +02:00
feat(ordering): optionally append includefiles to main config
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
include:
|
||||
- .install
|
||||
@@ -0,0 +1,48 @@
|
||||
# -*- 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 %}
|
||||
|
||||
include:
|
||||
- sudoers
|
||||
|
||||
{{ sudoers.includedir }}:
|
||||
file.directory:
|
||||
- user: root
|
||||
- group: {{ sudoers.group }}
|
||||
- mode: 750
|
||||
- clean: {{ sudoers.purge_includedir }}
|
||||
|
||||
{% set included_files = sudoers.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: {{ sudoers.includedir }}/{{ included_file }}
|
||||
{% endif %}
|
||||
- user: root
|
||||
- group: {{ sudoers.group }}
|
||||
- mode: 440
|
||||
- makedirs: True
|
||||
- template: jinja
|
||||
- source: salt://sudoers/files/sudoers
|
||||
- check_cmd: {{ sudoers.execprefix }}/visudo -c -f
|
||||
- context:
|
||||
included: True
|
||||
sudoers: {{ spec|json }}
|
||||
{% if sudoers.manage_main_config %}
|
||||
- require:
|
||||
- file: {{ sudoers.configpath }}/sudoers
|
||||
- require_in:
|
||||
- file: {{ sudoers.includedir }}
|
||||
{% elif sudoers.append_included_files_to_endof_main_config %}
|
||||
file.append:
|
||||
- name: {{ sudoers.configpath }}/sudoers
|
||||
- text: '#include {{ sudoers.configpath }}/sudoers.d/{{ included_file }}'
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user