Bug #3803
closedClean up Vectra IaC drift and add tests + usage docs
Description
Value: the Vectra IaC added under #3802 must be the single source of truth, reproducible and testable.
Acceptance criteria:
- Remove or reconcile stale static configs from 00cbe05 that drift from the rendered nginx/systemd/env files.
- Fix HF_HOME/model-path drift between the legacy files and the Ansible-rendered environment/systemd unit.
- Make scripts robust (no hardcoded cred paths, no shell-injected Python, JSON parsed properly, assertions in verification).
- Pin Python dependencies, make the Ansible inventory portable, and add offline + optional live tests.
- Add infra/README.md with exact usage, provisioning, verification, rollback and test commands.
MoSCoW: M. Points: 3. Follows #3802.
Updated by Fredrick Amnehagen about 5 hours ago
- Status changed from To do to In Progress
- Assignee set to Fredrick Amnehagen
Claimed by fredrick. Branch feature/3803-iac-cleanup-tests. Findings: stale static configs from 00cbe05 drift from the Ansible-rendered files; HF_HOME/model write path missing; Authelia vectra-users rules are not deployed (tracked separately in #3804).
Updated by Fredrick Amnehagen about 5 hours ago
- Status changed from In Progress to Done
- % Done changed from 0 to 100
Cleanup complete on feature/3803-iac-cleanup-tests. Commit a5e32cd3f32b6d30879eca01c16e28f006718ebc (Refs #3803). PR: https://forgejo.loopaware.com/Vectra/meta/pulls/2
Mistakes found and corrected:
- Stale static configs from 00cbe05 (env template, nginx site, systemd unit, server yml) drifted from the Ansible-rendered files; deleted so the playbook is the single source of truth.
- HF_HOME was not set in the rendered app env/unit and /opt/vectra/models was not a systemd ReadWritePaths entry; fixed and deployed.
- Python deps floated; pinned to versions validated on the LXC. Ansible inventory hardcoded /home/fredrick; now uses HOME lookup.
- env.sh hardcoded /home/fredrick cred path and injected it into inline Python; now reads INFRA_CONFIG as a parameter with configurable TF/jump nodes. provision/verify scripts used fragile grep/shell interpolation; now parse JSON in Python and assert real health/redirect targets. Provisioning now refuses to create a duplicate LXC when local OpenTofu state is missing and prints import guidance.
- nginx 25m body limit preempted the app's 25 MB validation error; raised to 26m.
- ROADMAP/AGENTS/SKILLS claimed vectra-users Authelia rules were live; live config on la-authelia-01 has no vectra rules, so claims were corrected and the gap moved to #3804. nginx 403 text no longer asserts a group restriction.
- Added infra/README.md usage guide plus offline and opt-in live tests (infra/scripts/test.sh).
Evidence: re-ran provision wrapper after fixes (Ansible applied changes, nginx health checks passed, [verify] PASS). bash infra/scripts/test.sh -> 10 passed, 2 live skipped. VECTRA_LIVE_TESTS=1 bash infra/scripts/test.sh -> 12 passed (tofu plan no-op + full live verify). Live check: /etc/vectra/vectra.env has HF_HOME=/opt/vectra/models; unit ReadWritePaths includes models; nginx client_max_body_size 26m.
Remaining: #3804 (dedicated Authelia rules) is intentionally open and blocked on an approved loopaware-infra-core template PR.