1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
# platform = multi_platform_all
# reboot = false
# strategy = restrict
# complexity = low
# disruption = low
{{% if VARIABLE_NAME %}}
{{{ ansible_instantiate_variables(VARIABLE_NAME) }}}
- name: Ensure {{{ OPTION }}} is enabled with the appropriate value in /etc/sudoers
lineinfile:
path: /etc/sudoers
regexp: '^[\s]*Defaults\s(.*)\b{{{ OPTION }}}=[-]?.+\b(.*)$'
line: 'Defaults \1{{{ OPTION }}}={{ {{{ VARIABLE_NAME }}} }}\2'
validate: /usr/sbin/visudo -cf %s
backrefs: yes
register: edit_sudoers_{{{ OPTION }}}_option
- name: Enable {{{ OPTION }}} option with appropriate value in /etc/sudoers
lineinfile: # noqa 503
path: /etc/sudoers
line: 'Defaults {{{ OPTION }}}={{ {{{ VARIABLE_NAME }}} }}'
validate: /usr/sbin/visudo -cf %s
when: edit_sudoers_{{{ OPTION }}}_option is defined and not edit_sudoers_{{{ OPTION }}}_option.changed
{{% else %}}
- name: Ensure {{{ OPTION }}} is enabled in /etc/sudoers
lineinfile:
path: /etc/sudoers
regexp: '^[\s]*Defaults.*\b{{{ OPTION }}}\b.*$'
line: 'Defaults {{{ OPTION }}}'
validate: /usr/sbin/visudo -cf %s
{{% endif %}}
|