47 lines
1.6 KiB
YAML
47 lines
1.6 KiB
YAML
- name: Install packages
|
|
when: 'os_flavor == "freebsd"'
|
|
package:
|
|
name:
|
|
- zsh
|
|
- py39-jmespath # Needed on machine running ansible for json_query
|
|
state: present
|
|
|
|
- name: Install packages
|
|
when: 'os_flavor == "linux"'
|
|
package:
|
|
name:
|
|
- zsh
|
|
- python-jmespath # Needed on machine running ansible for json_query
|
|
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
|