mirror of
https://github.com/roles-ansible/ansible_collection_users.git
synced 2024-08-16 10:29:50 +02:00
46 lines
1.4 KiB
YAML
46 lines
1.4 KiB
YAML
---
|
|
- name: Create Groups for Users
|
|
become: true
|
|
ansible.builtin.group:
|
|
name: "{{ item.name }}"
|
|
state: 'present'
|
|
loop: "{{ _l3d_users__merged_users }}"
|
|
loop_control:
|
|
label: "user: ['{{ item.name }}']"
|
|
when: item.state | default ('present') == 'present'
|
|
|
|
- name: Create Accounts for Users
|
|
become: true
|
|
ansible.builtin.user:
|
|
name: "{{ item.name }}"
|
|
group: "{{ item.name }}"
|
|
state: 'present'
|
|
create_home: "{{ item.create_home | default(true) }}"
|
|
comment: "User created by ansible"
|
|
shell: "{{ item.shell | default('/bin/bash') }}"
|
|
password: "{{ item.password | default() }}"
|
|
loop: "{{ _l3d_users__merged_users }}"
|
|
loop_control:
|
|
label: "user: ['{{ item.name }}']"
|
|
when: item.state | default ('present') == 'present'
|
|
|
|
- name: Remove Accounts for Users
|
|
become: true
|
|
ansible.builtin.user:
|
|
name: "{{ item.name }}"
|
|
state: 'absent'
|
|
remove: "{{ item.remove | default(false) }}"
|
|
loop: "{{ _l3d_users__merged_users }}"
|
|
loop_control:
|
|
label: "user: ['{{ item.name }}']"
|
|
when: item.state | default ('present') == 'absent' and item.remove | default(false) | bool
|
|
|
|
- name: Remove Groups for Users
|
|
become: true
|
|
ansible.builtin.group:
|
|
name: "{{ item.name }}"
|
|
state: 'absent'
|
|
loop: "{{ _l3d_users__merged_users }}"
|
|
loop_control:
|
|
label: "user: ['{{ item.name }}']"
|
|
when: item.state | default ('present') == 'absent' and item.remove | default(false) | bool
|