xoxys.users/tasks/users_default.yml

19 lines
721 B
YAML
Raw Normal View History

2019-11-03 17:19:53 +00:00
---
2024-02-18 12:27:45 +00:00
- name: Create groups
ansible.builtin.group:
name: "{{ item }}"
state: present
loop: "{{ users_default_groups }}"
2019-11-03 17:19:53 +00:00
2024-02-18 12:27:45 +00:00
- name: Create users
ansible.builtin.user:
name: "{{ item.name }}"
groups: "{{ item.groups | default([]) | join(',') or omit }}"
append: "{{ True if (item.groups | default([]) | length > 0) else False }}"
password: "{{ item.password | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) if item.password is defined else '*' }}"
2024-02-18 12:27:45 +00:00
password_expire_min: "{{ item.password_expire_min | default(users_pass_min_day) }}"
shell: "{{ item.shell | default('/bin/bash') }}"
loop: "{{ users_default_users }}"
loop_control:
label: "{{ item.name }}"