keycloak: first stand-up on a fresh host must not need its own registry #613

Öppen
öppnade 2026-10-08 21:12:23 +00:00 av supernaut · 2 kommentarer
Ägare

What

keycloak_image is {{ bitborg_registry_host }}/bitborg/bitborg-keycloak, the host's own Forgejo registry (group_vars/all/vars.yml:326). The Keycloak role pulls it with pull: true and no failure tolerance (roles/keycloak/tasks/main.yml:122-130). In site.yml the role runs before forgejo, billing, web and caddy (:66-72). Web and billing tolerate a missing image (soft pull, presence check, stage the unit).

Related to #575 (cutover) and #161 (full stand-up).

Why

A rebuild from backup must complete with one site.yml run.

Failing case

A full stand-up on a fresh prod host with keycloak_enabled: true. The Keycloak pull aborts the play, because the registry that serves the image is Forgejo, which has not been deployed yet.

Fix

Use the billing pattern: soft pull, podman image exists, stage the unit and skip the start when the image is absent. Alternatively move the Keycloak role after caddy. The first option keeps the role order the cutover plan assumes.

Done when

  • A full site.yml on a fresh staging host with keycloak_enabled: true finishes.
  • A second run starts Keycloak once the image is in the registry.
  • The stand-up checklist in the runbook names the second pass.

Plan outline

  1. Choose between soft pull (billing pattern) and moving the role after caddy.
  2. Stage the unit and skip the start when the image is absent.
  3. Add the second-pass apply to the stand-up checklist under #161.
  4. Prove it on a fresh staging host.
  5. Update the runbook.
## What `keycloak_image` is `{{ bitborg_registry_host }}/bitborg/bitborg-keycloak`, the host's own Forgejo registry (`group_vars/all/vars.yml:326`). The Keycloak role pulls it with `pull: true` and no failure tolerance (`roles/keycloak/tasks/main.yml:122-130`). In `site.yml` the role runs before `forgejo`, `billing`, `web` and `caddy` (`:66-72`). Web and billing tolerate a missing image (soft pull, presence check, stage the unit). Related to #575 (cutover) and #161 (full stand-up). ## Why A rebuild from backup must complete with one `site.yml` run. ## Failing case A full stand-up on a fresh prod host with `keycloak_enabled: true`. The Keycloak pull aborts the play, because the registry that serves the image is Forgejo, which has not been deployed yet. ## Fix Use the billing pattern: soft pull, `podman image exists`, stage the unit and skip the start when the image is absent. Alternatively move the Keycloak role after `caddy`. The first option keeps the role order the cutover plan assumes. ## Done when - [ ] A full `site.yml` on a fresh staging host with `keycloak_enabled: true` finishes. - [ ] A second run starts Keycloak once the image is in the registry. - [ ] The stand-up checklist in the runbook names the second pass. ## Plan outline 1. Choose between soft pull (billing pattern) and moving the role after caddy. 2. Stage the unit and skip the start when the image is absent. 3. Add the second-pass apply to the stand-up checklist under #161. 4. Prove it on a fresh staging host. 5. Update the runbook.
Upphovsperson
Ägare

Triage, 2026-10-11.

The Keycloak pull is fixed by #641 and #643. The role soft-pulls, stages the unit and skips the start, and the health gate drops Keycloak until the image is there. Web, billing, the reconciler and reconcile-trigger already soft-pull. No other image needs this host's registry at first boot.

A second first-pass blocker was fixed in #656. The forgejo role runs before caddy, so forgejo admin auth add-oauth could not fetch the discovery document and aborted the play. The add now tolerates only that error, and the second pass adds the source.

Rebuild order: pass 1 (clean stack), restore the databases and the storage tier (registry packages included), pass 2 (Keycloak starts, OIDC source added).

Still open:

  • A from-scratch stand-up with no restored realm fails the end-of-run health gate on realm discovery. It needs the opentofu/keycloak realm apply between the passes, or the checks gated on the realm existing.
  • Staging pulls from the prod registry, so a fresh staging host never exercises the missing-image path. Pin a tag that does not exist for one run to test it.
Triage, 2026-10-11. The Keycloak pull is fixed by #641 and #643. The role soft-pulls, stages the unit and skips the start, and the health gate drops Keycloak until the image is there. Web, billing, the reconciler and reconcile-trigger already soft-pull. No other image needs this host's registry at first boot. A second first-pass blocker was fixed in #656. The forgejo role runs before caddy, so `forgejo admin auth add-oauth` could not fetch the discovery document and aborted the play. The add now tolerates only that error, and the second pass adds the source. Rebuild order: pass 1 (clean stack), restore the databases and the storage tier (registry packages included), pass 2 (Keycloak starts, OIDC source added). Still open: - A from-scratch stand-up with no restored realm fails the end-of-run health gate on realm discovery. It needs the `opentofu/keycloak` realm apply between the passes, or the checks gated on the realm existing. - Staging pulls from the prod registry, so a fresh staging host never exercises the missing-image path. Pin a tag that does not exist for one run to test it.
Upphovsperson
Ägare

Status 2026-10-11: the first pass on a fresh host no longer aborts on the OIDC source (#656), and the runbook names the realm apply between the passes (#657). Open: a real fresh-host run, which is the done-when.

Status 2026-10-11: the first pass on a fresh host no longer aborts on the OIDC source (#656), and the runbook names the realm apply between the passes (#657). Open: a real fresh-host run, which is the done-when.
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra#613
Ingen beskrivning angiven.