feat(ops): 2fa review, safer teardown, off-site state copy, cost refresh #830

Sammanfogat
supernaut sammanfogade 8 incheckningar från feat/ops-scripts-2fa-teardown-state-cost in i main 2026-10-19 22:53:55 +00:00
Ägare

Closes

  • Closes #292: access-review-2fa.py takes --enrolments <csv> --rotated <date> (psql export from the runbook) and flags enrolments older than the rotation and admins with native TOTP and no passkey. Test: scripts/test_access_review_2fa.py, wired into CI.
  • Closes #610: teardown.sh destroys with -target on everything except prevent_destroy resources. Snapshot, backup and volume sweeps all skip items of protected volumes. Protected volumes are matched by ID from the state and by name from the tofu files; any failed lookup keeps the item. --plan-only previews the destroy and every sweep without deleting. --include-data-volumes destroys in a temp copy without prevent_destroy and copies the state back. --self-test (53 checks) added and wired into CI. Header, compute.tofu, outputs.tofu, runbook and opentofu/README.md corrected.
  • Closes #470: tofu-apply.sh copies the newest snapshot's terraform.tfstate* to the rclone destination in TOFU_STATE_OFFSITE_REMOTE. terraform.tfvars is plaintext and is not copied. Runbook entry added. Self-test extended to 9 checks.
  • Closes #469: cost/README.md example now prices the declared estate (1 386 SEK/month). Rates in prices.yml match docs/bahnhof-vpc.md. Cron line and systemd user timer documented.

Operator steps

Prod and staging share the opentofu/ root, state and project. teardown.sh acts on all of it. There is no staging-only run.

  • #610: scripts/teardown.sh --self-test (offline).
  • #610: scripts/teardown.sh --plan-only. It is read-only, not offline: it refreshes against the cloud, so it needs OpenStack credentials and the state passphrase. It runs tofu plan -destroy over the -target list and list-only sweeps. Read both by eye: no protected volume in the plan, every data volume, snapshot and backup under "keeping".
  • #610: do not run --yes or --include-data-volumes until a real teardown is intended.
  • #470 (prod operator step): configure an rclone remote, export TOFU_STATE_OFFSITE_REMOTE, then run scripts/tofu-apply.sh against prod state and check the object arrives.
  • #292 (prod operator step): run the ssh/psql export on the prod host and the review against prod with --enrolments/--rotated once. Delete the CSV.
  • #469: compare rates with the live Bahnhof calculator. Install the cron line or timer on the operator machine.
## Closes - Closes #292: `access-review-2fa.py` takes `--enrolments <csv> --rotated <date>` (psql export from the runbook) and flags enrolments older than the rotation and admins with native TOTP and no passkey. Test: `scripts/test_access_review_2fa.py`, wired into CI. - Closes #610: `teardown.sh` destroys with `-target` on everything except `prevent_destroy` resources. Snapshot, backup and volume sweeps all skip items of protected volumes. Protected volumes are matched by ID from the state and by name from the tofu files; any failed lookup keeps the item. `--plan-only` previews the destroy and every sweep without deleting. `--include-data-volumes` destroys in a temp copy without `prevent_destroy` and copies the state back. `--self-test` (53 checks) added and wired into CI. Header, `compute.tofu`, `outputs.tofu`, runbook and `opentofu/README.md` corrected. - Closes #470: `tofu-apply.sh` copies the newest snapshot's `terraform.tfstate*` to the rclone destination in `TOFU_STATE_OFFSITE_REMOTE`. `terraform.tfvars` is plaintext and is not copied. Runbook entry added. Self-test extended to 9 checks. - Closes #469: `cost/README.md` example now prices the declared estate (1 386 SEK/month). Rates in `prices.yml` match `docs/bahnhof-vpc.md`. Cron line and systemd user timer documented. ## Operator steps Prod and staging share the `opentofu/` root, state and project. `teardown.sh` acts on all of it. There is no staging-only run. - [ ] #610: `scripts/teardown.sh --self-test` (offline). - [ ] #610: `scripts/teardown.sh --plan-only`. It is read-only, not offline: it refreshes against the cloud, so it needs OpenStack credentials and the state passphrase. It runs `tofu plan -destroy` over the `-target` list and list-only sweeps. Read both by eye: no protected volume in the plan, every data volume, snapshot and backup under "keeping". - [ ] #610: do not run `--yes` or `--include-data-volumes` until a real teardown is intended. - [ ] #470 (prod operator step): configure an rclone remote, export `TOFU_STATE_OFFSITE_REMOTE`, then run `scripts/tofu-apply.sh` against prod state and check the object arrives. - [ ] #292 (prod operator step): run the ssh/psql export on the prod host and the review against prod with `--enrolments`/`--rotated` once. Delete the CSV. - [ ] #469: compare rates with the live Bahnhof calculator. Install the cron line or timer on the operator machine.
supernaut lade till 8 incheckningar 2026-10-19 19:10:34 +00:00
The API exposes no enrolment age, so the review takes the runbook psql
export plus the SECRET_KEY rotation date.

Closes #292
Step 1 aborted on prevent_destroy before the sweeps ran. It now targets
every managed resource except the protected volumes. Snapshot, backup and
volume sweeps all honour the protected set, derived from the tofu files.
--include-data-volumes destroys in a temp copy without prevent_destroy.

Closes #610
tofu-apply.sh pushes the newest snapshot's state files to the rclone
destination in TOFU_STATE_OFFSITE_REMOTE. tfvars is plaintext and stays
local. A failed copy warns and does not change the apply exit code.

Closes #470
Refs #470
The example now prices the declared estate. prices.yml rates were checked
against docs/bahnhof-vpc.md. Adds a cron line and systemd user timer.

Closes #469
Protection checks keep an item when a lookup fails or a predrill item has
no known source. Protected names, instance name and cloud are validated.
A failing state list aborts. State is snapshotted and copied back by
traps. Failed deletes are listed and exit non-zero. --plan-only gives an
offline destroy plan. Warns that prod and staging share the root.

Refs #610
Protected volume IDs are read from the state, so an unapplied rename
cannot expose a data volume. --plan-only now lists the sweeps without
deleting. Set-up copy failures abort, input files and env that tofu
would also read are refused, list errors count as failures, and items
without a source volume are kept.

Refs #610
fix(teardown): also disable SC2329 for the indirect self-test stubs
Alla kontroller lyckades
ci / ci (pull_request) Successful in 9m30s
b3de1dd8d8
shellcheck 0.11 reports never-invoked functions as SC2329, not SC2317.
supernaut sammanfogade incheckning 4d7275b81b till main 2026-10-19 22:53:55 +00:00
supernaut tog bort grenen feat/ops-scripts-2fa-teardown-state-cost 2026-10-19 22:53:56 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
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!830
Ingen beskrivning angiven.