incorporate sudo in common role

This commit is contained in:
Torma Kristóf 2022-04-17 14:38:46 +02:00
parent 231bc6752e
commit 645128198e
4 changed files with 17 additions and 24 deletions

View File

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

View File

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

View File

@ -1,17 +0,0 @@
---
- 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
...

View File

@ -33,6 +33,22 @@
owner: ansible owner: ansible
group: ansible group: ansible
- 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
- name: "Update authorized_keys of tormakris" - name: "Update authorized_keys of tormakris"
ansible.posix.authorized_key: ansible.posix.authorized_key:
user: tormakris user: tormakris