mirror of
https://github.com/natelandau/ansible-homelab-config.git
synced 2025-11-18 01:43:40 -05:00
fix: favor sudoers.d over lines in /etc/sudoers
This commit is contained in:
@@ -24,24 +24,18 @@
|
|||||||
when:
|
when:
|
||||||
- is_nomad_client or is_nomad_server
|
- is_nomad_client or is_nomad_server
|
||||||
|
|
||||||
- name: Ensure nomad user can run sudo with the restore script
|
- name: "SUDO: Confirm users can run service_backups"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/sudoers
|
path: "/etc/sudoers.d/010_{{ item }}-backups-nopasswd"
|
||||||
|
line: "{{ item }} ALL=(ALL) NOPASSWD: /usr/local/bin/service_backups, /usr/local/bin/service_restore"
|
||||||
state: present
|
state: present
|
||||||
line: "nomad ALL=(ALL) NOPASSWD: /usr/local/bin/service_backups, /usr/local/bin/service_restore"
|
create: true
|
||||||
validate: "/usr/sbin/visudo -cf %s"
|
mode: "0440"
|
||||||
when:
|
|
||||||
- is_nomad_client or is_nomad_server
|
|
||||||
- "'pis' in group_names"
|
|
||||||
|
|
||||||
- name: Ensure my user can run sudo with the restore script
|
|
||||||
become: true
|
|
||||||
ansible.builtin.lineinfile:
|
|
||||||
path: /etc/sudoers
|
|
||||||
state: present
|
|
||||||
line: "{{ ansible_user }} ALL=(ALL) NOPASSWD: /usr/local/bin/service_backups, /usr/local/bin/service_restore"
|
|
||||||
validate: "/usr/sbin/visudo -cf %s"
|
validate: "/usr/sbin/visudo -cf %s"
|
||||||
|
loop:
|
||||||
|
- nomad
|
||||||
|
- "{{ ansible_user }}"
|
||||||
when:
|
when:
|
||||||
- is_nomad_client or is_nomad_server
|
- is_nomad_client or is_nomad_server
|
||||||
- "'pis' in group_names"
|
- "'pis' in group_names"
|
||||||
|
|||||||
Reference in New Issue
Block a user