xoxys.users/tasks/users_univention.yml
Robert Kaussow 55c3698ae3
All checks were successful
continuous-integration/drone/push Build is passing
feat: add users option password_expire_min
2022-09-18 14:26:08 +02:00

26 lines
920 B
YAML

---
- block:
# use system users and groups to prevent duplicate ids
# this is a workaround because udm_user not working
- name: Create groups
group:
name: "{{ item }}"
system: "yes"
state: present
loop: "{{ users_default_groups }}"
- name: Create users
user:
name: "{{ item.name }}"
groups: "{{ item.groups | default([]) | join(',') or omit }}"
append: "{{ True if (item.groups | default([]) | length > 0) else False }}"
password: "{{ item.password | default(omit) | password_hash('sha512',65534 | random(seed=inventory_hostname) | string) }}"
password_expire_min: "{{ item.password_expire_min | default(omit) }}"
shell: "{{ item.shell | default('/bin/bash') }}"
system: "yes"
loop: "{{ users_default_users }}"
loop_control:
label: "{{ item.name }}"
become: True
become_user: root