1
0
Fork 0
mirror of synced 2024-11-25 02:05:36 -05:00
formula-sudoers/sudoers/files/sudoers

113 lines
4 KiB
Text
Raw Normal View History

{%- if (not included) %}
{%- set sudoers = pillar.get('sudoers', {}) %}
{%- if grains['os_family'] == 'Debian' %}
{%- set defaults = sudoers.get('defaults', {'generic': [
'env_reset',
'mail_badpass',
'secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"'
]}) %}
2014-07-30 05:10:50 -04:00
{%- set generic_defaults = defaults.get('generic', []) %}
{%- set user_list_defaults = defaults.get('user_list', {}) %}
{%- set host_list_defaults = defaults.get('host_list', {}) %}
{%- set command_list_defaults = defaults.get('command_list', {}) %}
{%- set runas_list_defaults = defaults.get('runas_list', {}) %}
{%- set users = sudoers.get('users', {'root': ['ALL=(ALL:ALL) ALL']}) %}
{%- set groups = sudoers.get('groups', {'sudo': ['ALL=(ALL:ALL) ALL']}) %}
2018-08-13 15:33:05 -04:00
{%- set netgroups = sudoers.get('netgroups', {}) %}
{%- else %}
{%- set defaults = sudoers.get('defaults', {}) %}
{%- set generic_defaults = defaults.get('generic', []) %}
{%- set user_list_defaults = defaults.get('user_list', {}) %}
{%- set host_list_defaults = defaults.get('host_list', {}) %}
{%- set command_list_defaults = defaults.get('command_list', {}) %}
{%- set runas_list_defaults = defaults.get('runas_list', {}) %}
{%- set users = sudoers.get('users', {}) %}
{%- set groups = sudoers.get('groups', {}) %}
2018-08-13 15:33:05 -04:00
{%- set netgroups = sudoers.get('netgroups', {}) %}
{%- endif %}
{%- set includedir = sudoers.get('includedir', '/etc/sudoers.d') -%}
{%- else %}
{%- set defaults = sudoers.get('defaults', {}) %}
{%- set generic_defaults = defaults.get('generic', []) %}
{%- set user_list_defaults = defaults.get('user_list', {}) %}
{%- set host_list_defaults = defaults.get('host_list', {}) %}
{%- set command_list_defaults = defaults.get('command_list', {}) %}
{%- set runas_list_defaults = defaults.get('runas_list', {}) %}
{%- set users = sudoers.get('users', {}) %}
{%- set groups = sudoers.get('groups', {}) %}
2018-08-13 15:33:05 -04:00
{%- set netgroups = sudoers.get('netgroups', {}) %}
{%- set includedir = sudoers.get('includedir', None) %}
{%- endif %}
2013-08-20 17:55:49 -04:00
{%- set aliases = sudoers.get('aliases', {}) %}
{%- set host_aliases = aliases.get('hosts', {}) %}
{%- set user_aliases = aliases.get('users', {}) %}
{%- set command_aliases = aliases.get('commands', {}) %}
{%- set runas_aliases = aliases.get('runas', {}) -%}
2013-08-20 17:32:58 -04:00
#
# This file is managed by salt
#
# Defaults specification
{% for default in generic_defaults -%}
2013-08-20 17:32:58 -04:00
Defaults {{ default }}
2013-08-20 17:45:11 -04:00
{% endfor %}
{%- for user,spec in user_list_defaults|dictsort %}
Defaults:{{ user }} {{ spec }}
{%- endfor %}
{%- for host,spec in host_list_defaults|dictsort %}
Defaults@{{ host }} {{ spec }}
{%- endfor %}
{%- for command,spec in command_list_defaults|dictsort %}
Defaults!{{ command }} {{ spec }}
{%- endfor %}
{%- for runas,spec in runas_list_defaults|dictsort %}
Defaults>{{ runas }} {{ spec }}
{%- endfor %}
2013-08-20 17:32:58 -04:00
# Host alias specification
{%- for name,hosts in host_aliases|dictsort %}
2013-08-20 17:45:11 -04:00
Host_Alias {{ name }} = {{ ",".join(hosts) }}
2013-08-20 17:54:21 -04:00
{%- endfor %}
2013-08-20 17:32:58 -04:00
# User alias specification
{%- for name,users in user_aliases|dictsort %}
2013-08-20 17:51:13 -04:00
User_Alias {{ name }} = {{ ",".join(users) }}
2013-08-20 17:54:21 -04:00
{%- endfor %}
2013-08-20 17:32:58 -04:00
# Cmnd alias specification
{%- for name,commands in command_aliases|dictsort %}
2013-08-20 17:51:13 -04:00
Cmnd_Alias {{ name }} = {{ ",".join(commands) }}
2013-08-20 17:54:21 -04:00
{%- endfor %}
2013-08-20 17:32:58 -04:00
# Runas alias specification
{%- for name,runas in runas_aliases|dictsort %}
2013-08-20 17:51:13 -04:00
Runas_Alias {{ name }} = {{ ",".join(runas) }}
2013-08-20 17:54:21 -04:00
{%- endfor %}
2013-08-20 17:32:58 -04:00
# User privilege specification
{%- for user,specs in users|dictsort %}
{%- for spec in specs %}
2013-08-20 17:51:13 -04:00
{{ user }} {{ spec }}
{%- endfor %}
2013-08-20 17:54:21 -04:00
{%- endfor %}
2013-08-20 17:32:58 -04:00
# Group privilege specification
{%- for group,specs in groups|dictsort %}
{%- for spec in specs %}
2013-08-20 17:51:13 -04:00
%{{ group }} {{ spec }}
{%- endfor %}
2013-08-20 17:54:21 -04:00
{%- endfor %}
2013-08-20 17:32:58 -04:00
2018-08-13 15:33:05 -04:00
# Netgroup privilege specification
{%- for netgroup,specs in netgroups.items() %}
{%- for spec in specs %}
+{{ netgroup }} {{ spec }}
{%- endfor %}
{%- endfor %}
2013-08-20 17:35:57 -04:00
{% if includedir %}
## Read drop-in files from /etc/sudoers.d
## (the '#' here does not indicate a comment)
#includedir {{ includedir }}
2013-08-20 17:32:58 -04:00
{% endif %}