Files
computer-playbook/roles/web-app-keycloak/tasks/update/07_userprofile.yml

49 lines
1.6 KiB
YAML

---
# Update the Declarative User Profile provider using the configuration
# from KEYCLOAK_DICTIONARY_REALM.components (same pattern as LDAP).
- name: "Extract UserProfileProvider component from realm dictionary"
set_fact:
kc_userprofile_tpl: >-
{{
KEYCLOAK_DICTIONARY_REALM.components['org.keycloak.userprofile.UserProfileProvider']
| list | first | default({})
}}
- name: "Sanity check: UserProfileProvider exists in dictionary"
assert:
that:
- kc_userprofile_tpl | length > 0
fail_msg: "UserProfileProvider component not found in KEYCLOAK_DICTIONARY_REALM."
when: MODE_ASSERT | bool
- name: "Resolve UserProfileProvider component ID"
shell: >
{{ KEYCLOAK_EXEC_KCADM }} get components
-r {{ KEYCLOAK_REALM }} --format json
| jq -r '
map(
select(
.providerType == "org.keycloak.userprofile.UserProfileProvider"
and .providerId == "declarative-user-profile"
)
)
| .[0].id // ""
'
register: kc_userprofile_id
changed_when: false
- name: "Update UserProfileProvider component (merge kc.user.profile.config)"
keycloak_kcadm_update:
object_kind: "component"
lookup_field: "id"
lookup_value: "{{ kc_userprofile_id.stdout | trim }}"
desired: "{{ kc_userprofile_tpl }}"
merge_path: "config"
kcadm_exec: "{{ KEYCLOAK_EXEC_KCADM }}"
realm: "{{ KEYCLOAK_REALM }}"
assert_mode: "{{ MODE_ASSERT }}"
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"