Browse Source

Add ansible depends and add admin group to sudoers

master
lavenderguiar 3 years ago
parent
commit
a0dcf4980f
  1. 18
      tasks/add_user.yml
  2. 9
      tasks/ansible_dependencies.yml
  3. 1
      tasks/main.yml

18
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 - name: add_user | Add admin user
user: user:
name: "{{ admin_user }}" name: "{{ admin_user }}"
@ -19,7 +33,7 @@
- name: add_user | Add SSH keys to admin user - name: add_user | Add SSH keys to admin user
authorized_key: authorized_key:
user: "{{ admin_user }}" user: "{{ admin_user }}"
state: "{{ item.state }}" state: present
key: "{{ item.key }}" key: "{{ item.key }}"
with_items: "{{ authorized_keys }}" with_items: "{{ ssh_keys }}"
become: yes become: yes

9
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"

1
tasks/main.yml

@ -1,4 +1,5 @@
--- ---
- include_tasks: ansible_dependencies.yml
- include_tasks: preflight.yml - include_tasks: preflight.yml
- include_tasks: add_user.yml - include_tasks: add_user.yml
- include_tasks: firewall.yml - include_tasks: firewall.yml
Loading…
Cancel
Save