You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.5 KiB
YAML
62 lines
1.5 KiB
YAML
---
|
|
|
|
- name: Read groups of realm {{ current_realm_name }}
|
|
uri:
|
|
url: http://localhost:{{ service_port_keycloak_external }}/auth/admin/realms/{{ current_realm_name }}/groups
|
|
method: GET
|
|
headers:
|
|
Authorization: "Bearer {{ access_token}} "
|
|
status_code: [200]
|
|
register: realm_groups
|
|
tags:
|
|
- create_groups
|
|
- update_realms
|
|
|
|
- name: Print realm groups
|
|
debug:
|
|
msg: "{{ realm_groups }}"
|
|
tags:
|
|
- create_groups
|
|
- update_realms
|
|
|
|
- name: Save realm groups as variable (fact)
|
|
set_fact:
|
|
realm_groups_json: "{{ realm_groups.json }}"
|
|
tags:
|
|
- create_groups
|
|
- update_realms
|
|
|
|
- name: Read realm group names
|
|
set_fact:
|
|
realm_groupnames: "{{ realm_groups_json | json_query(jmesquery) }}"
|
|
vars:
|
|
jmesquery: '[*].name'
|
|
tags:
|
|
- create_groups
|
|
- update_realms
|
|
|
|
- name: Print realm groupnames
|
|
debug:
|
|
msg: "{{ realm_groupnames }}"
|
|
tags:
|
|
- create_groups
|
|
- update_realms
|
|
|
|
- name: "Create groups for realm {{ current_realm_name }}"
|
|
uri:
|
|
url: http://localhost:{{ service_port_keycloak_external }}/auth/admin/realms/{{ current_realm_name }}/groups
|
|
method: POST
|
|
body_format: json
|
|
body: "{{ lookup('template','keycloak-realm-create-group.json.j2') }}"
|
|
headers:
|
|
Content-Type: "application/json"
|
|
Authorization: "Bearer {{ access_token }}"
|
|
status_code: [201]
|
|
with_items: "{{ current_realm_groups }}"
|
|
when: current_realm_group.name not in realm_groupnames
|
|
loop_control:
|
|
loop_var: current_realm_group
|
|
tags:
|
|
- create_groups
|
|
- update_realms
|