RouterOS 006: Secret handling for state and vars #68

Closed
opened 2026-11-14 01:41:05 +00:00 by ginjiruu · 2 comments
Owner

Part of #43

Refs: lab/iac#45
Migrated from router-as-code tracker 006 (docs/routeros/tracker in this repo history). Research notes: docs/routeros/notes/.

Terraform state holds device passwords in plaintext, so state security =
router admin security. iac#45 caveat; OpenBao later, sops today.

Decisions to make

  • Where per-device credentials live: SOPS-encrypted YAML in the iac repo
    rendered into the varsFrom Secret via the existing flow (how the other
    Terraform objects get theirs), vs ESO from OpenBao when it lands (mc#7 line
    of work). Start SOPS, keep the Secret name/shape stable so the swap is a
    source change only.
  • One dedicated terraform API user per router, group without full if
    policy coverage allows (test in sim), password rotated through the SAME
    secret (the bootstrap #002 sets it; rotation = bootstrap re-run on bench,
    which is allowed, vs editing the user over the API, which the protected-set
    rule forbids — see #002 rules).
  • The compiler output (#007) must render secrets from the same source, so a
    generated boot script contains real credentials only at render time in CI,
    never in git; golden renders use the CHANGEME-with-warning pattern borrowed
    from 1911-gold.

Done when

  • No plaintext credentials in either git repo; rotating the terraform user's
    password is a documented one-command change; state backend documented
    (controller-managed, in-cluster, access = flux-system).
Part of #43 Refs: lab/iac#45 Migrated from router-as-code tracker 006 (docs/routeros/tracker in this repo history). Research notes: docs/routeros/notes/. Terraform state holds device passwords in plaintext, so state security = router admin security. iac#45 caveat; OpenBao later, sops today. ## Decisions to make - Where per-device credentials live: SOPS-encrypted YAML in the iac repo rendered into the `varsFrom` Secret via the existing flow (how the other Terraform objects get theirs), vs ESO from OpenBao when it lands (mc#7 line of work). Start SOPS, keep the Secret name/shape stable so the swap is a source change only. - One dedicated `terraform` API user per router, group without `full` if policy coverage allows (test in sim), password rotated through the SAME secret (the bootstrap #002 sets it; rotation = bootstrap re-run on bench, which is allowed, vs editing the user over the API, which the protected-set rule forbids — see #002 rules). - The compiler output (#007) must render secrets from the same source, so a generated boot script contains real credentials only at render time in CI, never in git; golden renders use the `CHANGEME`-with-warning pattern borrowed from 1911-gold. ## Done when - No plaintext credentials in either git repo; rotating the terraform user's password is a documented one-command change; state backend documented (controller-managed, in-cluster, access = flux-system).
Author
Owner

Status 2026-11-17: ESO-from-OpenBao path shipped (secret/routeros-secrets on Bao, per-device ExternalSecret -> varsFrom, env-only secrets for the rollback fuse, iac#115/#119; no plaintext creds in git; cutover renders shredded after use). Gaps vs done-when: password rotation is not a documented one-command change, and state-backend doc line never written. Otherwise done; mark ready-for-human, likely closes with a docs note.

Status 2026-11-17: ESO-from-OpenBao path shipped (secret/routeros-secrets on Bao, per-device ExternalSecret -> varsFrom, env-only secrets for the rollback fuse, iac#115/#119; no plaintext creds in git; cutover renders shredded after use). Gaps vs done-when: password rotation is not a documented one-command change, and state-backend doc line never written. Otherwise done; mark ready-for-human, likely closes with a docs note.
Author
Owner

Detail 2026-11-17, what exactly is left (verified against live + master):

SHIPPED: Bao KV -> ESO (ClusterSecretStore openbao) -> routeros--env/-vars -> tf-runner env (ROS_PASSWORD, ROUTEROS_PASSWORD, ROLLBACK_BACKUP/PEER_PASSWORD). Zero plaintext creds in git; modules/rollback/main.tf keeps passwords env-only ('no password reaches state or a plan file'); dedicated REST-only terraform user with the group gate proven on CHR 7.25.1 (bootstrap README); renders shredded after use.

REMAINS (2 items, both docs):

  1. Rotation runbook (the one-command change). There is none written. Sequence to document (or script as task routeros:rotate-password HOST=...): generate -> set on the DEVICE first via REST /user with the CURRENT password, verify a login with the new one -> write Bao KV -> force ExternalSecret refresh (else up to 1h of 401 plans on the next reconcile) -> run one plan to confirm. Document why device-first (Bao-first leaves plans 401 until the device follows; device-first leaves the same window bounded by the manual refresh trigger) and that ROLLBACK_BACKUP_PASSWORD/ROLLBACK_PEER_PASSWORD are in scope: a stale one silently breaks the rollback fuse, which is exactly when it is needed.
  2. State-backend doc line (docs/routeros/README.md, one paragraph): state and plan live as in-cluster Secrets in flux-system (tfstate-default-routeros-, tfplan-); readable by anything with secrets there; no backup/restore story written. Defense-in-depth continues in #99 (transit-encrypt state); #98 is effectively satisfied for the routeros roots by the env-only design and can narrow to other roots.

Everything else in the body is decided and shipped. Suggest: write the two paragraphs (15 min, can do it in a docs PR on request), then close.

Detail 2026-11-17, what exactly is left (verified against live + master): SHIPPED: Bao KV -> ESO (ClusterSecretStore openbao) -> routeros-<dev>-env/-vars -> tf-runner env (ROS_PASSWORD, ROUTEROS_PASSWORD, ROLLBACK_BACKUP/PEER_PASSWORD). Zero plaintext creds in git; modules/rollback/main.tf keeps passwords env-only ('no password reaches state or a plan file'); dedicated REST-only terraform user with the group gate proven on CHR 7.25.1 (bootstrap README); renders shredded after use. REMAINS (2 items, both docs): 1. Rotation runbook (the one-command change). There is none written. Sequence to document (or script as task routeros:rotate-password HOST=...): generate -> set on the DEVICE first via REST /user with the CURRENT password, verify a login with the new one -> write Bao KV -> force ExternalSecret refresh (else up to 1h of 401 plans on the next reconcile) -> run one plan to confirm. Document why device-first (Bao-first leaves plans 401 until the device follows; device-first leaves the same window bounded by the manual refresh trigger) and that ROLLBACK_BACKUP_PASSWORD/ROLLBACK_PEER_PASSWORD are in scope: a stale one silently breaks the rollback fuse, which is exactly when it is needed. 2. State-backend doc line (docs/routeros/README.md, one paragraph): state and plan live as in-cluster Secrets in flux-system (tfstate-default-routeros-*, tfplan-*); readable by anything with secrets there; no backup/restore story written. Defense-in-depth continues in #99 (transit-encrypt state); #98 is effectively satisfied for the routeros roots by the env-only design and can narrow to other roots. Everything else in the body is decided and shipped. Suggest: write the two paragraphs (15 min, can do it in a docs PR on request), then close.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
lab/iac#68
No description provided.