File: ansible.template

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (30 lines) | stat: -rw-r--r-- 1,123 bytes parent folder | download | duplicates (2)
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 %}}