diff --git a/fix-sudoers.yaml b/fix-sudoers.yaml deleted file mode 100644 index 677d56b..0000000 --- a/fix-sudoers.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: "Fix ansible sudo stuff" - hosts: all - roles: - - ansible-sudo -... diff --git a/group_vars/all.yaml b/group_vars/all.yaml index 8748bce..f077a86 100644 --- a/group_vars/all.yaml +++ b/group_vars/all.yaml @@ -1,4 +1,4 @@ --- ansible_become: true -ansible_user: tormakris +ansible_user: ansible ... diff --git a/roles/ansible-sudo/tasks/main.yaml b/roles/ansible-sudo/tasks/main.yaml deleted file mode 100644 index 1b642fe..0000000 --- a/roles/ansible-sudo/tasks/main.yaml +++ /dev/null @@ -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 -... diff --git a/roles/common/tasks/user-ops.yaml b/roles/common/tasks/user-ops.yaml index 19bd53f..2f3abcd 100644 --- a/roles/common/tasks/user-ops.yaml +++ b/roles/common/tasks/user-ops.yaml @@ -33,6 +33,22 @@ owner: 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" ansible.posix.authorized_key: user: tormakris