Commit 76df5fcd authored by Pietsch, Martin's avatar Pietsch, Martin

added template for sudoers file

parent 372e47d9
{% macro _build_option_lines(defstat, _item) %}
{% set _line = namespace(value = defstat) %}
{% if (_item.enabled | default(true)) == false %}
{% set _line.value = _line.value + ' !' + _item.name %}
{% else %}
{% set _line.value = _line.value + ' ' + _item.name %}
{% endif %}
{% if ((_item.parameters | default([])) | length) > 0 %}
{% for _param in _item.parameters %}
{% if _param[0] != '+' and _param[0] != '-' %}
{{ '%s = "%s"' | format(_line.value, _param) -}}
{% elif _param[0] == '+' %}
{{ '%s += "%s"' | format(_line.value, _param | replace('+', '', 1)) -}}
{% else -%}
{{ '%s -= "%s"' | format(_line.value, _param | replace('-', '', 1)) -}}
{% endif %}
{% endfor -%}
{% else %}
{{ _line.value }}
{% endif %}
{% endmacro %}
# Alias specifications
{% for _sudo_aliases_item in sudo_aliases %}
{{ '%s_Alias %s = %s' | format(_sudo_aliases_item.type | capitalize, _sudo_aliases_item.name, _sudo_aliases_item.members | join(', ')) }}
{% endfor %}
# Defaults specifications
{% set _sudo_defaultdelim = {'host': '@', 'user': ':', 'cmnd': '!', 'runas': '>'} %}
{% for _sudo_defaults_item in sudo_defaults %}
{% if ((_sudo_defaults_item.type | default('all')) | lower()) == "all" %}
{{ _build_option_lines('Defaults', _sudo_defaults_item) -}}
{% else %}
{% for _sudo_assign in _sudo_defaults_item.assignto %}
{{ _build_option_lines('Defaults%s%s' | format(_sudo_defaultdelim[_sudo_defaults_item.type | lower()], _sudo_assign) , _sudo_defaults_item) -}}
{% endfor %}
{% endif %}
{% endfor %}
# User privilege specifications
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment