34 lines
1.6 KiB
YAML
34 lines
1.6 KiB
YAML
- name: Read existing PVE groups
|
|
ansible.builtin.command: pveum group list --output-format json
|
|
register: acl_groups
|
|
changed_when: false
|
|
check_mode: false
|
|
- name: Read existing PVE roles
|
|
ansible.builtin.command: pveum role list --output-format json
|
|
register: acl_roles
|
|
changed_when: false
|
|
check_mode: false
|
|
- name: Validate configured roles
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "'NoAccess' not in pve_roles"
|
|
- pve_roles | difference(acl_roles.stdout | from_json | map(attribute='roleid') | list) | length == 0
|
|
- name: Read existing PVE ACLs
|
|
ansible.builtin.command: pveum acl list --output-format json
|
|
register: acl_current
|
|
changed_when: false
|
|
check_mode: false
|
|
- name: Map each existing group on root with propagation
|
|
ansible.builtin.command:
|
|
argv: [pveum, acl, modify, /, --groups, "{{ item }}-{{ pve_realm }}", --roles, "{{ item }}", --propagate, '1']
|
|
loop: "{{ pve_roles }}"
|
|
when:
|
|
- (item ~ '-' ~ pve_realm) in (acl_groups.stdout | from_json | map(attribute='groupid') | list)
|
|
- acl_current.stdout | from_json | selectattr('path', 'equalto', '/') | selectattr('type', 'equalto', 'group') | selectattr('ugid', 'equalto', item ~ '-' ~ pve_realm) | selectattr('roleid', 'equalto', item) | selectattr('propagate', 'equalto', 1) | list | length == 0
|
|
changed_when: true
|
|
- name: Show groups awaiting their first OIDC login
|
|
ansible.builtin.debug:
|
|
msg: "{{ item }}-{{ pve_realm }} does not exist yet; log in a member through OIDC, then run playbook/acl.yml."
|
|
loop: "{{ pve_roles }}"
|
|
when: (item ~ '-' ~ pve_realm) not in (acl_groups.stdout | from_json | map(attribute='groupid') | list)
|