mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 22:06:31 +00:00
`_apply_one_role_special_rules()` in utils/manager/inventory.py used `bool(resolve_database_service_key(...))` to decide whether to auto-generate a `database_password` credential for a role. The resolver raises when multiple RDBMS keys are enabled — which is the correct contract for compose_volumes / container_depends_on / plugins.lookup.database (they need an unambiguous single key) but the wrong contract for inventory's credential-generation pass: variant 1 of svc-bkp-container-2-local intentionally enables both mariadb and postgres to exercise the engine-side dump path against both engines at once, and the deploy aborted with `ValueError: multiple direct database services are enabled: mariadb, postgres` during inventory generation (job 77602095377 on run 26362676803). Add a non-raising sibling helper `has_single_database_service()` that returns True iff exactly one RDBMS service is enabled, and switch inventory's call site to it. Multi-DB roles now skip the auto- generated `database_password` (which was a phantom credential for svc-bkp anyway — no schema.yml, no cross-role lookup; the role's own `04_seed-database-to-backup.yml` receives `database_password` as a caller-passed task var, not as a self-credential lookup). `resolve_database_service_key` keeps its strict raise semantics for the compose_volumes / container_depends_on / database-lookup callers, which still need a single unambiguous key. Add unit coverage for both functions (3 + 4 tests) in tests/unit/utils/roles/applications/services/test_database.py. Static check only (per operator request). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Application Utilities (utils/roles/applications/) 🧩
This package contains shared Python helpers that operate on the central applications configuration dictionary.
Purpose 🎯
Modules in utils/roles/applications/ MUST provide reusable helpers for reading, resolving, and validating application configuration.
Helpers MUST stay independent of Ansible plugin entrypoints so the same code can be imported from filter plugins, lookup plugins, and library modules.
Example Import ✍️
from utils.roles.applications import config
value = config.get(
applications,
application_id,
"features.oidc",
strict=False,
default=False,
)
Design Guidelines 📐
- Helpers SHOULD be focused, composable, and free of side effects during import.
- Helpers MUST NOT depend on Ansible plugin loader behavior at import time.
- Helpers SHOULD raise typed exceptions (e.g.
AppConfigKeyError) so callers can react to missing keys in strict mode. - Public functions SHOULD use concise names (e.g.
get) and rely on module-qualified access at call sites (config.get(...)) for clarity.
What Does Not Belong Here 🚫
- Standalone executable modules MUST live in
library/. - Ansible plugin entrypoints MUST live under
plugins/*. - Cross-cutting helpers that are not application-specific SHOULD live in the parent
utils/package instead.