2024-02-14 03:16:24 +01:00
|
|
|
---
|
|
|
|
- name: Create Groups for Users
|
|
|
|
become: true
|
|
|
|
ansible.builtin.group:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
state: 'present'
|
2024-02-14 21:25:00 +01:00
|
|
|
loop: "{{ _l3d_users__merged_users }}"
|
2024-02-14 03:16:24 +01:00
|
|
|
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() }}"
|
2024-02-14 21:25:00 +01:00
|
|
|
loop: "{{ _l3d_users__merged_users }}"
|
2024-02-14 03:16:24 +01:00
|
|
|
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) }}"
|
2024-02-14 21:25:00 +01:00
|
|
|
loop: "{{ _l3d_users__merged_users }}"
|
2024-02-14 03:16:24 +01:00
|
|
|
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'
|
2024-02-14 21:25:00 +01:00
|
|
|
loop: "{{ _l3d_users__merged_users }}"
|
2024-02-14 03:16:24 +01:00
|
|
|
loop_control:
|
|
|
|
label: "user: ['{{ item.name }}']"
|
|
|
|
when: item.state | default ('present') == 'absent' and item.remove | default(false) | bool
|