ansible: replace hand-copied literals with their variables #617

Stängd
öppnade 2026-10-08 21:12:24 +00:00 av supernaut · 0 kommentarer
Ägare

What

Four places hold a literal where a variable already exists. They drift silently on a rename.

  • roles/forgejo/templates/forgejo.container.j2:76 has Secret=gitborg-postgres-password. postgres_secret_name exists and the Postgres unit uses it.
  • keycloak_http_port and keycloak_management_port (group_vars/all/vars.yml:321,323) are not applied to Keycloak. roles/keycloak/files/healthcheck.sh:3 hardcodes 9000. The Quadlet unit sets no KC_HTTP_PORT or KC_HTTP_MANAGEMENT_PORT.
  • site.yml:135-144: health_check_services uses literal container names. It omits bitborg-billing and has no Keycloak endpoint.
  • The restic host tag is gitborg-prod in bitborg-backup-storage.sh.j2:77 and restore-on-scratch.sh.j2:301,304, while bitborg-backup-hot.sh.j2:40 uses inventory_hostname.

Why

A rename or port change in one place leaves the other behind and nothing fails until it matters.

Failing case

  • Change postgres_secret_name. Postgres follows. Forgejo still references the old name and podman create fails with "no such secret".
  • Set keycloak_management_port: 9001. vmagent scrapes :9001 while Keycloak listens on 9000. The metrics scrape goes dark.
  • A crash-looping billing unit, or a mis-rendered Keycloak Caddy block, passes the post-apply health gate.
  • The host tag changes in one script only. restic restore latest --host ... finds no snapshot and the drill fails. Both values agree today. Overlaps the hostname rename in #586, so check that issue first.

Fix

  • Use {{ postgres_secret_name }} in the Forgejo unit.
  • Add Environment=KC_HTTP_PORT=... and KC_HTTP_MANAGEMENT_PORT=... to the Keycloak unit. Template healthcheck.sh (or pass the port through the environment).
  • Build health_check_services from web_container_name, caddy_container_name and billing_container_name (when billing_enabled). Add a Keycloak /realms/<realm>/.well-known/openid-configuration endpoint when keycloak_enabled.
  • Add one backup_restic_host variable and use it in the storage backup and both restore scripts.

Done when

  • No literal remains for the four items above.
  • ansible-playbook --syntax-check and ansible-lint pass.
  • The health gate fails on a stopped billing unit when billing is enabled.
## What Four places hold a literal where a variable already exists. They drift silently on a rename. - `roles/forgejo/templates/forgejo.container.j2:76` has `Secret=gitborg-postgres-password`. `postgres_secret_name` exists and the Postgres unit uses it. - `keycloak_http_port` and `keycloak_management_port` (`group_vars/all/vars.yml:321,323`) are not applied to Keycloak. `roles/keycloak/files/healthcheck.sh:3` hardcodes 9000. The Quadlet unit sets no `KC_HTTP_PORT` or `KC_HTTP_MANAGEMENT_PORT`. - `site.yml:135-144`: `health_check_services` uses literal container names. It omits `bitborg-billing` and has no Keycloak endpoint. - The restic host tag is `gitborg-prod` in `bitborg-backup-storage.sh.j2:77` and `restore-on-scratch.sh.j2:301,304`, while `bitborg-backup-hot.sh.j2:40` uses `inventory_hostname`. ## Why A rename or port change in one place leaves the other behind and nothing fails until it matters. ## Failing case - Change `postgres_secret_name`. Postgres follows. Forgejo still references the old name and `podman create` fails with "no such secret". - Set `keycloak_management_port: 9001`. vmagent scrapes :9001 while Keycloak listens on 9000. The metrics scrape goes dark. - A crash-looping billing unit, or a mis-rendered Keycloak Caddy block, passes the post-apply health gate. - The host tag changes in one script only. `restic restore latest --host ...` finds no snapshot and the drill fails. Both values agree today. Overlaps the hostname rename in #586, so check that issue first. ## Fix - Use `{{ postgres_secret_name }}` in the Forgejo unit. - Add `Environment=KC_HTTP_PORT=...` and `KC_HTTP_MANAGEMENT_PORT=...` to the Keycloak unit. Template `healthcheck.sh` (or pass the port through the environment). - Build `health_check_services` from `web_container_name`, `caddy_container_name` and `billing_container_name` (when `billing_enabled`). Add a Keycloak `/realms/<realm>/.well-known/openid-configuration` endpoint when `keycloak_enabled`. - Add one `backup_restic_host` variable and use it in the storage backup and both restore scripts. ## Done when - [ ] No literal remains for the four items above. - [ ] `ansible-playbook --syntax-check` and `ansible-lint` pass. - [ ] The health gate fails on a stopped billing unit when billing is enabled.
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#617
Ingen beskrivning angiven.