2019-11-03 17:19:53 +00:00
|
|
|
---
|
|
|
|
- block:
|
2022-09-18 11:44:41 +00:00
|
|
|
- name: Create groups
|
2019-11-03 17:19:53 +00:00
|
|
|
group:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
2019-11-03 17:48:04 +00:00
|
|
|
loop: "{{ users_default_groups }}"
|
2019-11-03 17:19:53 +00:00
|
|
|
|
2022-09-18 11:44:41 +00:00
|
|
|
- name: Create users
|
2019-11-03 17:19:53 +00:00
|
|
|
user:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
groups: "{{ item.groups | default([]) | join(',') or omit }}"
|
2022-09-04 12:33:07 +00:00
|
|
|
append: "{{ True if (item.groups | default([]) | length > 0) else False }}"
|
2019-11-03 19:26:53 +00:00
|
|
|
password: "{{ item.password | password_hash('sha512',65534 | random(seed=inventory_hostname) | string) if item.password is defined else omit }}"
|
2022-09-20 06:49:42 +00:00
|
|
|
password_expire_min: "{{ item.password_expire_min | default(users_pass_min_day) }}"
|
2019-11-03 17:19:53 +00:00
|
|
|
shell: "{{ item.shell | default('/bin/bash') }}"
|
2019-11-03 17:48:04 +00:00
|
|
|
loop: "{{ users_default_users }}"
|
2019-11-03 17:19:53 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.name }}"
|
|
|
|
become: True
|
|
|
|
become_user: root
|