ansible sudo fix

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

6
fix-sudoers.yaml Normal file
View File

@ -0,0 +1,6 @@
---
- name: "Fix ansible sudo stuff"
hosts: all
roles:
- ansible-sudo
...

View File

@ -1,4 +1,4 @@
--- ---
ansible_become: true ansible_become: true
ansible_user: ansible ansible_user: tormakris
... ...

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