From f07b67106923c47c8d50696c53fa17818e1cc64e Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 12 Jul 2026 20:29:42 +0200 Subject: [PATCH] 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 --- .../tasks/03_keycloak_client.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/roles/web-app-opentalk/tasks/03_keycloak_client.yml b/roles/web-app-opentalk/tasks/03_keycloak_client.yml index 8f88691864..4fd6bf246c 100644 --- a/roles/web-app-opentalk/tasks/03_keycloak_client.yml +++ b/roles/web-app-opentalk/tasks/03_keycloak_client.yml @@ -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 }}"