diff --git a/ansiblefuckery.yaml b/ansiblefuckery.yaml deleted file mode 100644 index 0652db4..0000000 --- a/ansiblefuckery.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -- name: "Add ansible stuff" - hosts: all - roles: - - ansibleuser -... diff --git a/group_vars/all.yaml b/group_vars/all.yaml new file mode 100644 index 0000000..f077a86 --- /dev/null +++ b/group_vars/all.yaml @@ -0,0 +1,4 @@ +--- +ansible_become: true +ansible_user: ansible +... diff --git a/inventory.yaml b/inventory.yaml index d7127af..5bf4fc2 100644 --- a/inventory.yaml +++ b/inventory.yaml @@ -1,8 +1,5 @@ --- all: - vars: - ansible_become: true - ansible_user: tormakris children: woolsey: hosts: diff --git a/roles/ansibleuser/tasks/main.yaml b/roles/ansibleuser/tasks/main.yaml deleted file mode 100644 index 38dae6f..0000000 --- a/roles/ansibleuser/tasks/main.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -- name: "Add ansible user" - ansible.builtin.user: - name: ansible - comment: Ansible - shell: /bin/bash - -- name: "Add ansible user to sudo group" - ansible.builtin.user: - name: ansible - comment: Ansible - groups: sudo - append: yes - -- name: Create .ssh directory of root user - file: - path: /home/ansible//.ssh - state: directory - owner: ansible - group: ansible - -- name: Copy authorized_keys - copy: - src: authorized_keys - dest: /home/ansible/.ssh/authorized_keys - mode: 0600 - owner: ansible - group: ansible -... diff --git a/roles/ansibleuser/files/authorized_keys b/roles/common/files/authorized_keys similarity index 100% rename from roles/ansibleuser/files/authorized_keys rename to roles/common/files/authorized_keys diff --git a/roles/common/tasks/user-ops.yaml b/roles/common/tasks/user-ops.yaml index 195d58e..19bd53f 100644 --- a/roles/common/tasks/user-ops.yaml +++ b/roles/common/tasks/user-ops.yaml @@ -5,6 +5,34 @@ comment: Service user shell: /bin/bash +- name: "Add ansible user" + ansible.builtin.user: + name: ansible + comment: Ansible + shell: /bin/bash + +- name: "Add ansible user to sudo group" + ansible.builtin.user: + name: ansible + comment: Ansible + groups: sudo + append: yes + +- name: Create .ssh directory of root user + file: + path: /home/ansible/.ssh + state: directory + owner: ansible + group: ansible + +- name: Copy authorized_keys + copy: + src: authorized_keys + dest: /home/ansible/.ssh/authorized_keys + mode: 0600 + owner: ansible + group: ansible + - name: "Update authorized_keys of tormakris" ansible.posix.authorized_key: user: tormakris