-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(macro): to use in several state
- Loading branch information
Alkivi
committed
Apr 24, 2019
1 parent
00480b9
commit 70e66c9
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{%- macro sudoers(for_user, sudo, config, priority='20', state='present') -%} | ||
{%- set filename = priority ~ '-' ~ for_user|replace('.','-') ~ '-' ~ sudo %} | ||
|
||
{% if state == 'present' %} | ||
/etc/sudoers.d/{{ filename }}: | ||
file.managed: | ||
- user: root | ||
- group: root | ||
- mode: 440 | ||
- template: jinja | ||
- source: salt://sudoers/templates/sudoers.jinja | ||
- context: | ||
for_user: {{ for_user }} | ||
sudo: {{ sudo }} | ||
config: {{ config }} | ||
|
||
{% elif state == 'absent' %} | ||
/etc/sudoers.d/{{ filename }}: | ||
file.absent | ||
{% endif %} | ||
|
||
{%- endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{%- if config.command is string -%} | ||
{{ for_user }} {{ config.privileges }}: {{ config.command }} | ||
{%- else -%} | ||
{% for command in config.command -%} | ||
{{ for_user }} {{ config.privileges }}: {{ command }} | ||
{% endfor %} | ||
{%- endif -%} |