mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-09 12:17:13 +00:00
Every Ansible rescue: block used to carry ad-hoc per-role failure dumps that drifted apart and captured different subsets. Replace them all with one diagnostics script (scripts/system/diagnostics/rescue.sh) that snapshots containers (full logs plus inspect per container), swarm services (ps plus logs per service), journal, host resources, runtime info and stats into a per-run folder and always exits 1 so the deploy still fails. A new lint enforces the shape: every rescue ends with the script, at most one nocheck-justified extra task before it (postgres pg_hba dump, xwiki extension-repo probe), and a nocheck rescue-recovery exemption for the one block that must genuinely recover: keycloak object updates, where a cross-node reschedule needs a swarm-wide node re-resolve plus a delegate_to change that only a rescue can express; its recovery is kept and now also captures diagnostics before the terminal failure. The snapshot folder path is a group_vars SPOT: DIR_RESCUE_DIAGNOSTICS and DIR_VAR_LIB live in group_vars/all/05_paths.yml as plain strings; new env handlers derive INFINITO_RESCUE_DIAGNOSTICS_DIR and INFINITO_DIR_VAR_LIB from it for the generated .env, replacing the default.env entries, and the play-level environment forwards the value to every task host so rescue.sh needs no second default. CI uploads the folder like the inventory and playwright artifacts: compose copies it out of the deploy container in dedicated.sh, swarm captures per node (manager and both workers) into node-named subfolders. Deleting the ad-hoc dumps orphaned helper files (postgres inspect_container, terminator docker_diagnostics, peertube diagnostics, matomo bootstrap debug, xwiki and openresty rescue includes) and 14 role vars; all removed. Generic pieces of those dumps (runtime version and info, stats, dmesg oom evidence, swapon) moved into the SPOT script instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
utils/env 📐
This directory hosts the Python implementation behind make dotenv.
For the general rules that govern READMEs in code directories see documentation.md.
For the per-variable defaults that this code consumes see default.env.
Purpose 🎯
The package converts the committed default.env plus a small runtime context into the gitignored .env at the repo root.
Every module here belongs to one of four roles: parse, resolve, orchestrate, write.
Structure 🗂️
| File | Role |
|---|---|
parser.py |
Read default.env into (values, comments) tuples. |
runtime.py |
Resolve host-context lookups (disk, RAM, hostname, GHA/Act flags, /proc/version, helper-script invocation). |
builder.py |
Thin orchestrator that defines EnvBuilder, BuildContext, and build_env(). Walks the handler registry. |
writer.py |
Serialise an EnvBuilder into a docker-compose-compatible .env on disk. |
handlers/ |
One module per dynamically-computed variable. See handlers README. |
The CLI entry point lives at __main__.py under cli/meta/env/.
Shell consumers source load.sh under scripts/meta/env/.
File Naming 🏷️
- Module names MUST stay lowercase snake_case.
- Pure passthrough or simple parser/writer helpers MUST live directly under
utils/env/. - Per-variable computation MUST live under
handlers/(see handlers README for the naming convention used there). - Test files live in tests/unit/utils/env/ and mirror the module name with a
test_prefix.
Import Rules 🔗
parser.py,runtime.py, andwriter.pyMUST NOT import frombuilder.pyorhandlers/.builder.pyMUST NOT import individual handler modules; it MUST go through theORDERED_HANDLERSlist exposed byhandlers/__init__.py.- Handler modules MUST NOT import each other (see handlers README).