ansible sudo fix

This commit is contained in:
2022-04-17 14:36:26 +02:00
parent a3deafec54
commit 231bc6752e
3 changed files with 24 additions and 1 deletions

View 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
...