ansible sudo fix
This commit is contained in:
17
roles/ansible-sudo/tasks/main.yaml
Normal file
17
roles/ansible-sudo/tasks/main.yaml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Check if ansible is already nopasswd in sudoers
|
||||
lineinfile:
|
||||
state: absent
|
||||
path: /etc/sudoers
|
||||
regexp: "^ansible"
|
||||
check_mode: true
|
||||
changed_when: false
|
||||
register: checkallowusers
|
||||
|
||||
- name: Define ansible nopasswd in sudoers
|
||||
lineinfile:
|
||||
state: present
|
||||
path: /etc/sudoers
|
||||
line: "ansible ALL=(ALL:ALL) NOPASSWD"
|
||||
when: checkallowusers.found == 0
|
||||
...
|
Reference in New Issue
Block a user