diff --git a/tasks/add_user.yml b/tasks/add_user.yml index 06340ed..d13deaf 100644 --- a/tasks/add_user.yml +++ b/tasks/add_user.yml @@ -1,4 +1,18 @@ --- +- name: add_user | Add admin group + group: + name: "{{ admin_group }}" + state: present + +- name: add_user | Allow 'admin' group to have passwordless sudo + lineinfile: + dest: /etc/sudoers + state: present + regexp: '^%admin' + line: '%admin ALL=(ALL) NOPASSWD: ALL' + validate: 'visudo -cf %s' + become: yes + - name: add_user | Add admin user user: name: "{{ admin_user }}" @@ -19,7 +33,7 @@ - name: add_user | Add SSH keys to admin user authorized_key: user: "{{ admin_user }}" - state: "{{ item.state }}" + state: present key: "{{ item.key }}" - with_items: "{{ authorized_keys }}" + with_items: "{{ ssh_keys }}" become: yes \ No newline at end of file diff --git a/tasks/ansible_dependencies.yml b/tasks/ansible_dependencies.yml new file mode 100644 index 0000000..163f9c5 --- /dev/null +++ b/tasks/ansible_dependencies.yml @@ -0,0 +1,9 @@ +--- +- name: linode-preflight | Install Python + raw: test -e /usr/bin/python || (sudo apt-get -y update && sudo apt-get install -y python2-minimal) + register: common__pyout + become: yes + changed_when: + - False + - common__pyout.stdout != "" + - common__pyout.stderr != "\r\n" \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 0c8a227..dac84ee 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,4 +1,5 @@ --- +- include_tasks: ansible_dependencies.yml - include_tasks: preflight.yml - include_tasks: add_user.yml - include_tasks: firewall.yml \ No newline at end of file