You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
887 B
39 lines
887 B
---
|
|
- 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 }}"
|
|
group: "{{ admin_group }}"
|
|
state: present
|
|
create_home: yes
|
|
become: yes
|
|
|
|
- name: add_user | Ensure admin user ssh directory exists
|
|
file:
|
|
path: "/home/{{ admin_user }}/.ssh/"
|
|
state: directory
|
|
owner: "{{ admin_user }}"
|
|
group: "{{ admin_group }}"
|
|
mode: 0700
|
|
become: yes
|
|
|
|
- name: add_user | Add SSH keys to admin user
|
|
authorized_key:
|
|
user: "{{ admin_user }}"
|
|
state: present
|
|
key: "{{ item.key }}"
|
|
with_items: "{{ ssh_keys }}"
|
|
become: yes
|