2022-10-10 03:36:22 +00:00
|
|
|
- name: Install packages
|
|
|
|
when: 'os_flavor == "freebsd"'
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- zsh
|
2022-10-11 01:50:39 +00:00
|
|
|
- py39-jmespath # Needed on machine running ansible for json_query
|
2022-10-10 03:36:22 +00:00
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Install packages
|
|
|
|
when: 'os_flavor == "linux"'
|
|
|
|
package:
|
|
|
|
name:
|
|
|
|
- zsh
|
2022-10-11 01:50:39 +00:00
|
|
|
- python-jmespath # Needed on machine running ansible for json_query
|
2022-10-10 03:36:22 +00:00
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create group
|
|
|
|
group:
|
|
|
|
name: "{{ item.value.group | default(item.key) }}"
|
|
|
|
gid: "{{ item.value.gid | default(omit) }}"
|
|
|
|
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`]') }}"
|
|
|
|
|
|
|
|
- name: Create group
|
|
|
|
group:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
gid: "{{ item.gid | default(omit) }}"
|
|
|
|
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].value.groups') | flatten }}"
|
|
|
|
|
|
|
|
- name: Create user
|
|
|
|
user:
|
|
|
|
name: "{{ item.key }}"
|
|
|
|
group: "{{ item.value.group | default(item.key) }}"
|
|
|
|
groups: "{{ item.value.groups | community.general.json_query('[*].name') }}"
|
|
|
|
shell: "{{ item.value.shell | default('/usr/local/bin/zsh') }}"
|
|
|
|
uid: "{{ item.value.uid | default(omit) }}"
|
|
|
|
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`]') }}"
|
|
|
|
when: item.value.groups is defined
|
|
|
|
|
|
|
|
- name: Create user
|
|
|
|
user:
|
|
|
|
name: "{{ item.key }}"
|
|
|
|
group: "{{ item.value.group | default(item.key) }}"
|
|
|
|
shell: "{{ item.value.shell | default('/usr/local/bin/zsh') }}"
|
|
|
|
uid: "{{ item.value.uid | default(omit) }}"
|
|
|
|
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`]') }}"
|
|
|
|
when: item.value.groups is not defined
|