2018-08-22 18:42:52 +00:00
|
|
|
---
|
2022-01-05 10:25:33 +00:00
|
|
|
# tasks file for users
|
2020-03-17 04:44:48 +00:00
|
|
|
- name: users -- Ensure wheel group exists
|
2019-09-09 19:30:58 +00:00
|
|
|
group:
|
|
|
|
name: wheel
|
|
|
|
state: present
|
|
|
|
|
2020-07-16 14:47:04 +00:00
|
|
|
- name: create users
|
2022-01-05 10:25:33 +00:00
|
|
|
ansible.builtin.user:
|
2018-08-22 19:18:18 +00:00
|
|
|
name: "{{ item.username }}"
|
2022-01-05 10:25:33 +00:00
|
|
|
update_password: on_create
|
2019-12-14 15:48:53 +00:00
|
|
|
password: "{{ item.password | password_hash('sha512')}}"
|
2019-05-11 16:30:41 +00:00
|
|
|
group: "{{ item.group }}"
|
2019-05-12 04:39:55 +00:00
|
|
|
groups: "{{ item.groups }}"
|
2022-01-05 10:25:33 +00:00
|
|
|
shell: "{{ item.shell | default('/bin/bash') }}"
|
2019-03-06 08:28:19 +00:00
|
|
|
state: present
|
2022-01-05 10:25:33 +00:00
|
|
|
system: "{{ item.system | default('no') }}"
|
|
|
|
createhome: "{{ item.createhome | default('no') }}"
|
2020-07-16 14:47:04 +00:00
|
|
|
with_items: "{{ users }}"
|
2018-08-23 12:29:20 +00:00
|
|
|
|
2020-07-16 15:37:34 +00:00
|
|
|
- name: ssh -- Add public key
|
|
|
|
authorized_key:
|
|
|
|
user: "{{ item.user.username }}"
|
2022-01-05 10:25:33 +00:00
|
|
|
key: "{{ lookup('file', item.key) }}"
|
2020-07-16 15:37:34 +00:00
|
|
|
state: present
|
|
|
|
with_items: "{{ public_key }}"
|