ansible sudo fix
This commit is contained in:
parent
a3deafec54
commit
231bc6752e
6
fix-sudoers.yaml
Normal file
6
fix-sudoers.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: "Fix ansible sudo stuff"
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- ansible-sudo
|
||||||
|
...
|
@ -1,4 +1,4 @@
|
|||||||
---
|
---
|
||||||
ansible_become: true
|
ansible_become: true
|
||||||
ansible_user: ansible
|
ansible_user: tormakris
|
||||||
...
|
...
|
||||||
|
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
|
||||||
|
...
|
Loading…
Reference in New Issue
Block a user