From a0dcf4980ff12e2317979cd6dbec89586dc83aa4 Mon Sep 17 00:00:00 2001 From: lavenderguiar Date: Sat, 30 Oct 2021 18:53:19 -0400 Subject: [PATCH] Add ansible depends and add admin group to sudoers --- tasks/add_user.yml | 18 ++++++++++++++++-- tasks/ansible_dependencies.yml | 9 +++++++++ tasks/main.yml | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 tasks/ansible_dependencies.yml 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