Feat: init refact with test
This commit is contained in:
26
roles/users/tasks/main.yml
Normal file
26
roles/users/tasks/main.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
# tasks file for users
|
||||
- name: users -- Ensure wheel group exists
|
||||
group:
|
||||
name: wheel
|
||||
state: present
|
||||
|
||||
- name: create users
|
||||
ansible.builtin.user:
|
||||
name: "{{ item.username }}"
|
||||
update_password: on_create
|
||||
password: "{{ item.password | password_hash('sha512')}}"
|
||||
group: "{{ item.group }}"
|
||||
groups: "{{ item.groups }}"
|
||||
shell: "{{ item.shell | default('/bin/bash') }}"
|
||||
state: present
|
||||
system: "{{ item.system | default('no') }}"
|
||||
createhome: "{{ item.createhome | default('no') }}"
|
||||
with_items: "{{ users }}"
|
||||
|
||||
- name: ssh -- Add public key
|
||||
authorized_key:
|
||||
user: "{{ item.user.username }}"
|
||||
key: "{{ lookup('file', item.key) }}"
|
||||
state: present
|
||||
with_items: "{{ public_key }}"
|
||||
Reference in New Issue
Block a user