From 8f5c0e63ad47ce9a0b624f85fe10d4e488800a77 Mon Sep 17 00:00:00 2001 From: spektr Date: Mon, 30 Nov 2026 19:17:54 +0100 Subject: [PATCH] GNAI-025: read-only Verify-Playbook playbooks/verify.yml (Doku 1.17) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Health-Check des produktiven Stacks (production-Inventory, alle Tasks read-only): systemd-Unit, 24 Container + seaweedfs-init Exited(0), interner Caddy-Edge (SPA-Shell x_fluxer_app_shell, version.json, Discovery, Admin 200, Gateway 426, LiveKit, SSO-Status enabled), öffentlicher Pfad via NPM (Login + identisches Discovery-Dokument), Keycloak-Realm-Discovery (Issuer + authorization_code), SSO-Start-Probe (PKCE S256 + client_binding), SSO-Complete-Junk-Probe (400), app-proxy-Log frei von Branding-404s (DISCOVERY-Fix-Wächter) - SSO-Proben abschaltbar (fluxer_verify_sso_probes_enabled=false); Browser-Login/Logout bleiben manuelle Abnahmeschritte (10a) - Zwei Läufe grün: ok=24, changed=0, failed=0; README um Operational-verification-Abschnitt erweitert Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- .../ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md | 5 + proxmox/lxc/ct-117-fluxer/ansible/README.md | 28 ++ .../ansible/playbooks/verify.yml | 315 ++++++++++++++++++ 3 files changed, 348 insertions(+) create mode 100644 proxmox/lxc/ct-117-fluxer/ansible/playbooks/verify.yml diff --git a/docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md b/docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md index 481f3fd..88c324f 100644 --- a/docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md +++ b/docs/platform/proxmox-server/lxc/ct-117-fluxer/GNAI-025-PLAN_Fluxer-LXC.md @@ -24,6 +24,7 @@ | 2026-11-30 | 1.14 | Mistral Vibe | **Befund f revidiert — Caddy-Edge als interner Edge aktiviert:** das app-proxy-only-Routing war unvollständig (die SPA lud, aber /api, /gateway, /media, /admin, Static-Assets fielen auf den SPA-Fallback des app-proxy — die App war faktisch nicht bedienbar). NPM bleibt TLS-Edge; der gepinnte Upstream-Caddy läuft auf CT 117 als interner HTTP-Edge auf :8082 (`FLUXER_CADDY_SITE_ADDRESS=:8082`, kein ACME) und routed laut gepinnter Caddyfile alle Pfade zu den Compose-Services. NPM-Vhost: alles → 10.0.0.62:8082 (WS-Upgrade, lange Timeouts), /livekit/-Location entfernt (caddy routed). App-proxy-Port 8080 und LiveKit-Signaling 7880 nicht mehr gepublisht; Firewall: NPM → 8082 (input + DNAT-forward). Verifiziert: `/api/auth/sso/status` öffentlich 200 (echte API-Antwort), `/admin/login` 200, `/.well-known/fluxer` 200; CT-117- und CT-103-Zweitläufe `changed=0` | | 2026-11-30 | 1.15 | Mistral Vibe / Operator | **Setup + SSO + Voice-Ports eingerichtet (Phasen 8/10):** Setup-Screen per FLUXER_SETUP_TOKEN abgeschlossen (Injection siehe voriger Commit), erster Account = Instance-Admin, SSO im Admin-Panel konfiguriert (enabled, Issuer `https://auth.ghostnet.selfhost.eu/realms/Ghost.net`, Client `fluxer`), FRITZ!Box-Portweiterleitungen (7881/tcp, 7882/udp, 3478/udp, 50000-50100/udp → 10.0.0.62) erstellt. Agent-seitige Abnahme grün: `/auth/sso/start` liefert echte Keycloak-Authorization-URL (PKCE S256), OIDC-Discovery vom CT 117 aus HTTP 200, Gateway-WS (426) und LiveKit-Signaling (401) routen durch NPM→Caddy ohne SPA-Fallback, 7881/tcp offen, 8082 vom LAN geblockt (NPM-exklusiv), unattended-upgrades aktiv. Offen bleiben die Browser-Checks des Operators: SSO-Login, Invite-only-Verifikation im UI, Voice-Call über WAN | | 2026-11-30 | 1.16 | Mistral Vibe / Operator | **SSO-Abnahme abgeschlossen — Logout-Einschränkung dokumentiert und vom Operator akzeptiert („verkraftbar"):** a) SSO-Login vollständig verifiziert (Browser-E2E im gesteuerten Chromium inkl. Keycloak-TOTP + Operator-Login in Firefox/Chromium, normal + privat): `sso/start` → Keycloak (PKCE S256) → Callback → `sso/complete` 200 → Gateway READY. Wichtig für curl-Nachtests: der deployte Build (Stable Web 2026.1124.195247, neuer als der gepinnte Quellcode 3b1eb567) verlangt bei `POST /auth/sso/complete` das `client_binding` aus der Start-Response — ohne → 400 „Invalid or expired SSO state" (State wird dabei konsumiert). b) **DISCOVERY_UPSTREAM_URL-Fix deployiert** (war im Repo vorbereitet, Lauf site35 unterbrochen): der app-proxy pollte alle ~5 min `http://api:8080/api/.well-known/fluxer` → 404 (caddy-:8088-Pfad stript `/api`); korrigiert auf `http://api:8080/.well-known/fluxer` im compose-Override; Läufe site36/site37, Zweitlauf `changed=0`, Branding-404-Warnungen im app-proxy-Log beseitigt. c) **Logout-Bug charakterisiert** (Detail Abschnitt 10a): serverseitig korrekt (POST `/api/v1/auth/logout` → 204, Gateway-Reset, Session beendet), aber die SPA rendert nach Logout innerhalb der gleichen Seitenlebensdauer nach SSO-Login statt der Login-Seite die Callback-Fehlerseite „SSO sign-in failed" mit totem „Back to sign-in"-Button; Workaround einmal F5. Upstream-Bug (auch im fluxer-main Stand 30.11.), kein lokaler Handlungsbedarf. d) **Firefox-LNA-Befund** (Abschnitt 10b): 1502 Client-Cancels (NPM 499) ausschließlich Firefox/161 — Firefox' Local Network Access bricht Requests von der öffentlichen Domain auf die private IP (10.0.0.10) ab; Verstärker für Chunk-/SRI-Stürme und „transport gave up after retries" beim Operator; Abhilfe workstation-lokal (about:config). Chrome/curl nicht betroffen | +| 2026-11-30 | 1.17 | Mistral Vibe | **Verify-Playbook ergänzt** (`playbooks/verify.yml` im CT-117-Ansible-Projekt, README aktualisiert): read-only Health-Check des produktiven Stacks gegen das production-Inventory — systemd-Unit aktiv, 24 Services running (seaweedfs-init `Exited (0)`), interner Caddy-Edge (SPA-Shell (`x_fluxer_app_shell`), version.json, Discovery, Admin-Panel 200, Gateway 426, LiveKit-Routing, SSO-Status `enabled=true`), öffentlicher Pfad über NPM (Login-Seite + identisches Discovery-Dokument), Keycloak-Realm-Discovery (Issuer + authorization_code), SSO-Start-Probe (PKCE S256 + `client_binding`, Client `fluxer`), SSO-Complete-Junk-Probe (400 INVALID_OR_EXPIRED_SSO_STATE) und app-proxy-Log frei von Branding-404-Warnungen (DISCOVERY-Fix-Wächter). Beide SSO-Proben erzeugen nur kurzlebige, von selbst ablaufende Serverzustände (abschaltbar via `fluxer_verify_sso_probes_enabled=false`); Browser-Login/Logout bleiben Operator-Abnahmeschritte (10a). Zwei Läufe grün: ok=24, changed=0, failed=0 | ## 1. Zweck und Leitentscheidung @@ -193,6 +194,7 @@ ihn. ## 8. Betrieb (SOP, Auszug) - Status: `ssh -F ~/.ssh/config ghostnet-ct117-agent 'sudo /usr/local/bin/fluxer-readonly podman ps'`; Logs: `podman logs` / `journalctl -u fluxer-stack`. +- Health-Check: `playbooks/verify.yml` auf production (read-only, s. Projekt-README); deckt Unit, Container, Edge-Endpunkte, öffentlichen Pfad, Keycloak-Discovery und die SSO-Proben ab — nach Wartung/Restore/Pin-Update laufen. - Stack-Neustart nach Pin-Update: `site.yml`-Re-Run (production) oder manuell `systemctl restart fluxer-stack` auf CT 117. - Backup: vzdump-Job (PVE) deckt CT 117; App-level (Postgres+SeaweedFS) als restic zu ghostnet-ki ist offen (Abschnitt 11). @@ -210,6 +212,9 @@ ihn. 4. Firewall: von extern nur 80/443 (via FRITZ!Box→CT 103) und ggf. Voice-Ports erreichbar; `nft list table inet ghostnet_filter` auf CT 117 zeigt die gesetzten Regeln; direkter Zugriff auf 10.0.0.62:8080 nur von 10.0.0.10. 5. Idempotenz: zweiter `site.yml`-Lauf `changed=0`; preflight auf agent-Inventory clean. 6. Unattended-Upgrades: `unattended-upgrades.service` aktiv, Origins-Pattern nur Debian-Security. +7. Automatisierbar: Punkte 1–3 (ohne Voice-Call und Browser-Login) deckt + `playbooks/verify.yml` ab (siehe 1.17); Browser-SSO-Login/Logout und + Voice-Call bleiben manuelle Operator-Checks (10a). ### 10a. Abnahmebefund Logout (2026-11-30, Operator: verkraftbar) diff --git a/proxmox/lxc/ct-117-fluxer/ansible/README.md b/proxmox/lxc/ct-117-fluxer/ansible/README.md index 55a11f8..8e19fac 100644 --- a/proxmox/lxc/ct-117-fluxer/ansible/README.md +++ b/proxmox/lxc/ct-117-fluxer/ansible/README.md @@ -63,3 +63,31 @@ CT 101/114 procedure: The stack is started by `site.yml` only on inventories with `fluxer_stack_start_allowed: true` (production). + +## Operational verification + +`playbooks/verify.yml` is a read-only health check for the running stack +(run it on `production`; it needs sudo for podman/journal access, every task +reports `changed=0`): + +```bash +../../../../.venv/bin/ansible-playbook \ + --inventory inventories/production/hosts.yml \ + playbooks/verify.yml \ + --private-key ~/.ssh/id_ed25519_ghostnet_ct117_ansible_deploy +``` + +It asserts: `fluxer-stack.service` active, all 24 services running with the +seaweedfs-init oneshot `Exited (0)`, the internal caddy edge serving the SPA +shell (`x_fluxer_app_shell`), `version.json`, the discovery document, the +admin panel, the gateway upgrade requirement (426), LiveKit routing and the +SSO status (`enabled=true`); the public path through NPM (login page + +matching discovery document); the Keycloak realm discovery document with the +configured issuer and the authorization-code grant; the SSO start handing +out a PKCE S256 authorization URL with `client_binding` for the `fluxer` +client (and `/auth/sso/complete` rejecting junk states with 400); and the +app-proxy log being free of branding discovery 404 warnings (the +`DISCOVERY_UPSTREAM_URL` guard). Two SSO probes create only expiring +server-side sign-in state; disable them with +`fluxer_verify_sso_probes_enabled=false`. Full browser SSO login/logout +remains a manual operator acceptance step (GNAI-025 Abschnitt 10/10a). diff --git a/proxmox/lxc/ct-117-fluxer/ansible/playbooks/verify.yml b/proxmox/lxc/ct-117-fluxer/ansible/playbooks/verify.yml new file mode 100644 index 0000000..576f1d2 --- /dev/null +++ b/proxmox/lxc/ct-117-fluxer/ansible/playbooks/verify.yml @@ -0,0 +1,315 @@ +--- +# Read-only operational verification of the CT 117 Fluxer stack (GNAI-025 +# Abschnitt 10). Run it whenever the stack should prove itself healthy, +# e.g. after maintenance, restores or upgrades: +# +# cd proxmox/lxc/ct-117-fluxer/ansible +# ../../../../.venv/bin/ansible-playbook \ +# --inventory inventories/production/hosts.yml \ +# playbooks/verify.yml \ +# --private-key ~/.ssh/id_ed25519_ghostnet_ct117_ansible_deploy +# +# Every task is read-only (changed_when: false). Two SSO probes create only +# short-lived server-side sign-in state (an SSO start nonce / one rejected +# complete attempt) that expires on its own; disable them with +# fluxer_verify_sso_probes_enabled=false. Full browser SSO login/logout remains +# a manual operator acceptance step (Abschnitt 10/10a). Requires the +# production inventory: podman and journal access need sudo, and the public +# probes resolve the split DNS name through NPM (CT 103). + +- name: Read-only operational verification of the CT 117 Fluxer stack + hosts: fluxer_hosts + become: true + gather_facts: false + + vars: + # Internal edge (upstream Caddy, GNAI-025 Befund f) only reachable from + # the guest itself and the NPM host; probes run locally on CT 117. + fluxer_verify_local_base: http://127.0.0.1:8082 + # Keycloak identity of this instance (GNAI-025 Abschnitt 4). + fluxer_verify_keycloak_discovery_url: >- + https://auth.ghostnet.selfhost.eu/realms/Ghost.net/.well-known/openid-configuration + fluxer_verify_keycloak_issuer: https://auth.ghostnet.selfhost.eu/realms/Ghost.net + # All services except the seaweedfs-init oneshot (Exited (0) is healthy). + fluxer_verify_expected_running: 24 + fluxer_verify_init_container: fluxer_seaweedfs-init_1 + fluxer_verify_sso_probes_enabled: true + fluxer_verify_app_proxy_warning_patterns: + - "discovery returned 404" + + tasks: + - name: Verify the fluxer-stack systemd unit is active + ansible.builtin.command: + argv: + - /usr/bin/systemctl + - is-active + - fluxer-stack.service + register: fluxer_verify_unit + changed_when: false + failed_when: false + + - name: Assert the fluxer-stack unit is active + ansible.builtin.assert: + that: + - fluxer_verify_unit.stdout | trim == "active" + fail_msg: >- + fluxer-stack.service is "{{ fluxer_verify_unit.stdout | trim }}". + Inspect with `systemctl status fluxer-stack` and + `journalctl -u fluxer-stack` on CT 117. + + - name: Read the Fluxer container states + ansible.builtin.command: + argv: + - /usr/bin/podman + - ps + - -a + - --format + - json + register: fluxer_verify_ps + changed_when: false + + - name: Assert every compose service is healthy (24 running, init Exited (0)) + # seaweedfs-init is a oneshot S3 bootstrap container: Exited (0) is its + # healthy terminal state (GNAI-025 1.11 Befund f); anything else that is + # not running, or any failed exit code, fails the verification. + vars: + fluxer_verify_containers: "{{ fluxer_verify_ps.stdout | from_json }}" + fluxer_verify_running: >- + {{ fluxer_verify_containers | selectattr('State', 'equalto', 'running') | list }} + fluxer_verify_not_running: >- + {{ fluxer_verify_containers | rejectattr('State', 'equalto', 'running') | list }} + # Names is a list in podman ps --format json; everything that is not + # running and not the healthy oneshot init container is a failure. + fluxer_verify_unhealthy: >- + {{ fluxer_verify_not_running | + rejectattr('Names', 'equalto', [fluxer_verify_init_container]) | list }} + fluxer_verify_init_ok: >- + {{ fluxer_verify_not_running | + selectattr('Names', 'equalto', [fluxer_verify_init_container]) | + selectattr('ExitCode', 'equalto', 0) | list }} + ansible.builtin.assert: + that: + - fluxer_verify_running | length == fluxer_verify_expected_running | int + - fluxer_verify_unhealthy | length == 0 + - fluxer_verify_init_ok | length == fluxer_verify_not_running | length + fail_msg: >- + Expected {{ fluxer_verify_expected_running }} running containers, found + {{ fluxer_verify_running | length }}. Not running: + {{ fluxer_verify_not_running | map(attribute='Names') | map('join', ' ') | join(', ') }} + Inspect with `podman ps -a` and `podman logs ` on CT 117. + + - name: Probe the internal edge — SPA shell + ansible.builtin.uri: + url: "{{ fluxer_verify_local_base }}/" + status_code: 200 + register: fluxer_verify_spa + changed_when: false + + - name: Assert the SPA shell is the Fluxer app + # The app-proxy marks its shell responses with x_fluxer_app_shell. + ansible.builtin.assert: + that: + - fluxer_verify_spa.status == 200 + - fluxer_verify_spa.x_fluxer_app_shell is defined + - fluxer_verify_spa.x_fluxer_app_shell == "1" + - fluxer_verify_spa.content_type is search('text/html') + fail_msg: >- + The caddy edge did not serve the app-proxy SPA shell at / + (status {{ fluxer_verify_spa.status | default('n/a') }}). + + - name: Probe the internal edge — version.json + ansible.builtin.uri: + url: "{{ fluxer_verify_local_base }}/version.json" + status_code: 200 + register: fluxer_verify_version + changed_when: false + + - name: Assert version.json reports a build version + ansible.builtin.assert: + that: + - fluxer_verify_version.json.version is defined + - fluxer_verify_version.json.version | length > 0 + fail_msg: >- + version.json did not report a build version + (status {{ fluxer_verify_version.status | default('n/a') }}). + + - name: Probe the internal edge — instance discovery document + ansible.builtin.uri: + url: "{{ fluxer_verify_local_base }}/.well-known/fluxer" + status_code: 200 + register: fluxer_verify_discovery + changed_when: false + + - name: Assert the discovery document advertises the public API endpoint + ansible.builtin.assert: + that: + - fluxer_verify_discovery.json.endpoints.api is defined + - fluxer_verify_keycloak_issuer is search('ghostnet') + - >- + fluxer_verify_discovery.json.endpoints.api is + search(fluxer_stack_public_domain) + fail_msg: >- + The /.well-known/fluxer document does not advertise the public API + endpoint of {{ fluxer_stack_public_domain }} + (status {{ fluxer_verify_discovery.status | default('n/a') }}). + + - name: Probe the internal edge — admin panel, gateway, livekit, SSO status + ansible.builtin.uri: + url: "{{ fluxer_verify_local_base }}{{ item.path }}" + status_code: "{{ item.status }}" + loop: + - path: /admin/login + status: 200 + - path: /gateway + status: 426 + - path: /livekit/ + status: 200 + - path: /api/auth/sso/status + status: 200 + loop_control: + label: "{{ item.path }}" + register: fluxer_verify_paths + changed_when: false + + - name: Assert SSO is enabled in the auth status document + ansible.builtin.assert: + that: + - (fluxer_verify_paths.results | selectattr('item.path', 'equalto', '/api/auth/sso/status') | list | first).json.enabled | bool + fail_msg: >- + /api/auth/sso/status did not report enabled=true — SSO is switched + off; check the admin panel instance settings. + + - name: Probe the public path through NPM — login page + ansible.builtin.uri: + url: "https://{{ fluxer_stack_public_domain }}/login" + status_code: 200 + register: fluxer_verify_public_login + changed_when: false + + - name: Assert the public login page is served with a valid certificate + ansible.builtin.assert: + that: + - fluxer_verify_public_login.status == 200 + - fluxer_verify_public_login.url is search('^https://') + fail_msg: >- + https://{{ fluxer_stack_public_domain }}/login failed through NPM + (CT 103). Check the NPM vhost, the LE certificate and the CT 117 + firewall forward rules. + + - name: Probe the public path through NPM — instance discovery + ansible.builtin.uri: + url: "https://{{ fluxer_stack_public_domain }}/.well-known/fluxer" + status_code: 200 + register: fluxer_verify_public_discovery + changed_when: false + + - name: Assert the public discovery document matches the internal one + ansible.builtin.assert: + that: + - >- + fluxer_verify_public_discovery.json.api_code_version == + fluxer_verify_discovery.json.api_code_version + fail_msg: >- + The public and internal /.well-known/fluxer documents differ — + NPM may terminate at the wrong target (expected the CT 117 caddy + edge 10.0.0.62:8082). + + - name: Probe the Keycloak OIDC discovery document + ansible.builtin.uri: + url: "{{ fluxer_verify_keycloak_discovery_url }}" + status_code: 200 + register: fluxer_verify_kc_discovery + changed_when: false + + - name: Assert Keycloak advertises the configured realm issuer + ansible.builtin.assert: + that: + - fluxer_verify_kc_discovery.json.issuer == fluxer_verify_keycloak_issuer + - >- + 'authorization_code' in fluxer_verify_kc_discovery.json.grant_types_supported + fail_msg: >- + The Keycloak discovery document at + {{ fluxer_verify_keycloak_discovery_url }} did not report the + expected issuer {{ fluxer_verify_keycloak_issuer }} or lacks the + authorization-code flow. + + - name: Probe SSO start (harmless, creates an expiring sign-in nonce) + ansible.builtin.uri: + url: "{{ fluxer_verify_local_base }}/api/v1/auth/sso/start" + method: POST + body: "{}" + headers: + Content-Type: application/json + status_code: 200 + when: fluxer_verify_sso_probes_enabled | bool + register: fluxer_verify_sso_start + changed_when: false + + - name: Assert the SSO start hands out the Keycloak authorization URL + # The deployed build requires client_binding from this response at + # /auth/sso/complete (GNAI-025 1.16) — asserting it also catches an + # unexpected downgrade to an older app build. + when: fluxer_verify_sso_probes_enabled | bool + ansible.builtin.assert: + that: + - fluxer_verify_sso_start.json.authorization_url is defined + - fluxer_verify_sso_start.json.state is defined + - fluxer_verify_sso_start.json.client_binding is defined + - fluxer_verify_sso_start.json.authorization_url is search(fluxer_verify_keycloak_issuer) + - fluxer_verify_sso_start.json.authorization_url is search('client_id=fluxer') + - fluxer_verify_sso_start.json.authorization_url is search('code_challenge_method=S256') + fail_msg: >- + POST /api/v1/auth/sso/start did not return a usable PKCE S256 + authorization URL for the fluxer client (got: + {{ fluxer_verify_sso_start.status | default('n/a') }}). + + - name: Probe SSO complete with a junk state (must be rejected cleanly) + ansible.builtin.uri: + url: "{{ fluxer_verify_local_base }}/api/v1/auth/sso/complete" + method: POST + body: '{"code":"verify-probe-junk","state":"verify-probe-junk"}' + headers: + Content-Type: application/json + status_code: 400 + when: fluxer_verify_sso_probes_enabled | bool + register: fluxer_verify_sso_complete + changed_when: false + + - name: Assert the SSO state guard rejects junk without leaking + when: fluxer_verify_sso_probes_enabled | bool + ansible.builtin.assert: + that: + - fluxer_verify_sso_complete.status == 400 + - >- + fluxer_verify_sso_complete.json.errors is defined + fail_msg: >- + POST /api/v1/auth/sso/complete did not reject a junk state with the + expected 400 INVALID_OR_EXPIRED_SSO_STATE (got: + {{ fluxer_verify_sso_complete.status }}). + + - name: Scan the app-proxy log for branding discovery failures + # DISCOVERY_UPSTREAM_URL fix (GNAI-025 1.16b): the app-proxy must fetch + # http://api:8080/.well-known/fluxer without 404s; any occurrence of + # the warning patterns since boot means the compose override drifted. + ansible.builtin.command: + argv: + - /usr/bin/podman + - logs + - fluxer_app-proxy_1 + register: fluxer_verify_app_proxy_logs + changed_when: false + + - name: Assert the app-proxy branding refresh is free of 404 warnings + vars: + fluxer_verify_log_hits: >- + {{ fluxer_verify_app_proxy_logs.stderr_lines | + select('search', fluxer_verify_app_proxy_warning_patterns | join('|')) | + list }} + ansible.builtin.assert: + that: + - fluxer_verify_log_hits | length == 0 + fail_msg: >- + The app-proxy logged branding discovery failures since boot: + {{ fluxer_verify_log_hits[:3] | join(' ; ') }}. The + DISCOVERY_UPSTREAM_URL compose override has drifted — inspect + /opt/fluxer/docker-compose.ghostnet.yml on CT 117.