Debian Codegraph @

tests/image_prep/roles/sudoers/tasks/main.yml

raw
1 - name: Ensure correct sudo group exists
2 group:
3 name: "{{ sudo_group[ansible_distribution] }}"
4
5 - name: Sanitize /etc/sudoers.d
6 file:
7 path: "{{ item.path }}"
8 mode: "{{ item.mode | default(omit) }}"
9 state: "{{ item.state }}"
10 with_items:
11 - {path: /etc/sudoers.d, state: directory, mode: u=rwx,go=}
12 - {path: /etc/sudoers.d/README, state: absent}
13
14 - name: Allow wheel members to sudo
15 lineinfile:
16 path: /etc/sudoers
17 regexp: '#* *%wheel +ALL=\((?:ALL:ALL|ALL)\) +ALL'
18 line: "%wheel ALL=(ALL) ALL"
19 validate: '/usr/sbin/visudo -cf %s'
20 when:
21 - ansible_os_family in ['Alpine', 'RedHat']
22
23 - name: Include sudoers.d
24 lineinfile:
25 path: /etc/sudoers
26 regexp: '#+includedir +/etc/sudoers\.d'
27 line: '#includedir /etc/sudoers.d'
28 validate: '/usr/sbin/visudo -cf %s'
29
30 - name: Configure sudoers
31 copy:
32 src: "{{ item.src }}"
33 dest: "{{ item.dest }}"
34 mode: ug=r,o=
35 validate: '/usr/sbin/visudo -cf %s'
36 with_items: "{{ sudoers_d_configs }}"
37
38 - name: Configure local sudoers
39 template:
40 src: "{{ item.src }}"
41 dest: "{{ item.dest }}"
42 mode: ug=r,o=
43 validate: '/usr/sbin/visudo -cf %s'
44 with_items:
45 - {src: local_user, dest: /etc/sudoers.d/mitogen_test_local_user}
46 when:
47 - ansible_connection == "local"