xoxys.users/tasks/users_univention.yml

26 lines
920 B
YAML
Raw Normal View History

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