fix(opentalk): gate kcadm provisioning on a healthy keycloak

The single-shot master-realm login raced a keycloak container that had
just been recreated and answered its warm-up window with
unauthorized_client. Adopt the same guard web-app-keycloak's own login
uses: resolve the cid with --filter health=healthy, wait for the
container to report healthy, and retry the kcadm login.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
kevinveenbirkenbachandClaude Fable 5 committed 2026-07-12 21:13:39 +02:00
1 parent 3a2ef3da01
commit f07b671069
1 file changed
+16
@@ -8,6 +8,18 @@
resolve_compose_cid: "{{ OPENTALK_KEYCLOAK_CONTAINER_ADDRESS }}"
resolve_converge_retries: 60
resolve_converge_delay: 5
resolve_cid_filters: "--filter health=healthy"
- name: "⏳ Wait for the Keycloak container to be healthy before OpenTalk provisioning"
ansible.builtin.shell: >
container inspect --format '{{ "{{" }}.State.Health.Status{{ "}}" }}'
{{ OPENTALK_KEYCLOAK_LOCAL_CID | quote }}
register: opentalk_kc_health
retries: 60
delay: 5
until: (opentalk_kc_health.stdout | trim) == 'healthy'
changed_when: false
delegate_to: "{{ OPENTALK_KEYCLOAK_HOST_NODE }}"
- name: "✅ Authenticate kcadm against master realm for OpenTalk provisioning"
ansible.builtin.shell: |-
@@ -23,6 +35,10 @@
KEYCLOAK_EXEC_CONTAINER: "container exec -i {{ OPENTALK_KEYCLOAK_LOCAL_CID | quote }}" # nocheck: container-exec-resolver OPENTALK_KEYCLOAK_LOCAL_CID resolved at delegate_to runtime
KEYCLOAK_KCADM: "/opt/keycloak/bin/kcadm.sh"
KEYCLOAK_SERVER_INTERNAL_URL: "http://127.0.0.1:8080"
register: opentalk_kcadm_login
retries: 6
delay: 10
until: opentalk_kcadm_login.rc == 0
delegate_to: "{{ OPENTALK_KEYCLOAK_HOST_NODE }}"
changed_when: false
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"