RouterOS #65: device roots (rb5009-a, rb5009-b, crs309) #111

Merged
ginjiruu merged 4 commits from routeros-devicetrees-65 into master 2026-11-16 21:04:10 +00:00
Owner

Part of #43. Closes #65 (the apply-and-clean-week part runs at the cutover, #73; the objects ship suspended).

What lands

  • routeros/rb5009-a/, routeros/rb5009-b/: one state per device, instantiating modules/site + modules/router (index 0/1, vrrp_priority 200/100), tls block wired like routeros/sim (www-ssl cert from pki-net-caosh/routeros via vault_pki_secret_backend_cert → routeros_system_certificate → certificate binding on the existing www-ssl service; the service itself stays bootstrap-owned, #64). Providers pinned: terraform-routeros/routeros ~> 1.99 (lock: 1.99.1), hashicorp/vault ~> 5.6 (lock: 5.13.0) - same pair as the sim lock.
  • routeros/crs309/: first cut, no switch module exists. Inline L2 derived from site data: identity, NTP, VLAN-aware bridge, VLAN table from modules/site networks, trunks to the router pair (defaults sfp-sfpplus7/8, lab port plan; access ports empty until the #44 hardware map). Not sim-proven - the lab switch stand-in is a Linux bridge; verify on hardware at bench.
  • All three roots: hosturl = https://<var.routeros_host> (TF_VAR, pre-DNS runs override), username = terraform, password sensitive TF_VAR arriving from the controller varsFrom Secret (only *.tfvars.example placeholders committed), routeros_version pinned via var (7.25.1), no backend block - exactly what harbor/ vault/ declare; the tofu-controller injects state config.
  • Vault auth mirrors harbor/provider.tf: skip_child_token + auth_login_jwt at kubernetes-mini, role tf-routeros (SA already exists, vault/runners-k8s.tf). vault/ untouched.
  • task routeros:guard (script scripts/routeros-guard.sh): fails if a device root declares routeros_system_user, routeros_system_user_sshkeys, routeros_ip_service or routeros_ip_address (type names verified against the 1.99 provider schema via tofu providers schema). Scans root .tf only - the module's www-ssl binding (day 2, #64) stays legal. Verified both ways: clean roots pass, an planted routeros_ip_address/routeros_system_user is caught with a pointer to adoption.md. task routeros:validate added too (init -backend=false + validate + fmt per root).
  • docs/routeros/adoption.md: one page in #66 shape - protected set, what roots own, reset-vs-import adoption, import { to = module.router..., id = "name=bridge" } recipe.

Deliberate deviation from the suggested CA data source

The routeros provider's ca_certificate takes a file path, and the tf-routeros role's policy is issue-only (verified on the harness OpenBao: path "pki-net-caosh/issue/routeros" { capabilities = ["update"] }), so data.vault_generic_secret on pki-net-caosh/cert/ca would 403 at plan time - and the verification anchor the proven flow uses is the lab root, not the zone CA (sim/main.tf passes a root file, renewal-test.sh and lab-router-certs.sh verify against it; the leaf chains pki-net-caosh → pki-issue → lab root). So var.lab_root_ca_path defaults to /etc/lab-ca/root.crt, the lab-root-ca configMap the flux-clusters objects mount for the same runner (identical to VAULT_CACERT). If we later want a Vault read instead, the tf-routeros policy needs a read grant - separate vault/ change, not here.

Validation (no devices touched; registry reachable)

  • tofu init -backend=false && tofu validate → Success! The configuration is valid. in all three roots.
  • tofu fmt -check -recursive → clean in all three.
  • Guard: OK clean / FAIL planted (exit 1).
  • No tofu plan/apply anywhere; lab untouched.

Open questions (for the coordinator)

  1. Bootstrap mgmt-address collision: the module creates vlan10-mgmt/vlan1001-legacy-mgmt + addresses 10.30.10.2/.3, 10.16.1.61/.62. The #64 renderer must not put its day-1 address under one of those names/addresses (or bench prep removes it first) - documented in adoption.md.
  2. crs309 www-ssl cert day-2 rotation has no owner yet (vault provider pinned there for exactly that).
  3. The routeros-secrets KV (routeros-secrets/RB5009_{A,B}_PASSWORD, CRS309_PASSWORD, PPPOE_{A,B}_{USER,PASSWORD}) must be seeded before un-suspending; ESO routeros-*-vars stay NotReady until then (flux-clusters PR).
  4. PPPoE defaults: roots plan without a PPPoE client until credentials arrive (#46/#73).
Part of #43. Closes #65 (the apply-and-clean-week part runs at the cutover, #73; the objects ship suspended). ## What lands - `routeros/rb5009-a/`, `routeros/rb5009-b/`: one state per device, instantiating `modules/site` + `modules/router` (index 0/1, vrrp_priority 200/100), tls block wired like `routeros/sim` (www-ssl cert from `pki-net-caosh/routeros` via `vault_pki_secret_backend_cert` → `routeros_system_certificate` → certificate binding on the existing `www-ssl` service; the service itself stays bootstrap-owned, #64). Providers pinned: `terraform-routeros/routeros ~> 1.99` (lock: 1.99.1), `hashicorp/vault ~> 5.6` (lock: 5.13.0) - same pair as the sim lock. - `routeros/crs309/`: first cut, no switch module exists. Inline L2 derived from site data: identity, NTP, VLAN-aware bridge, VLAN table from `modules/site` networks, trunks to the router pair (defaults `sfp-sfpplus7/8`, lab port plan; access ports empty until the #44 hardware map). **Not sim-proven** - the lab switch stand-in is a Linux bridge; verify on hardware at bench. - All three roots: `hosturl = https://<var.routeros_host>` (TF_VAR, pre-DNS runs override), `username = terraform`, `password` sensitive TF_VAR arriving from the controller `varsFrom` Secret (only `*.tfvars.example` placeholders committed), `routeros_version` pinned via var (7.25.1), **no backend block** - exactly what harbor/ vault/ declare; the tofu-controller injects state config. - Vault auth mirrors `harbor/provider.tf`: `skip_child_token` + `auth_login_jwt` at `kubernetes-mini`, role `tf-routeros` (SA already exists, `vault/runners-k8s.tf`). `vault/` untouched. - `task routeros:guard` (script `scripts/routeros-guard.sh`): fails if a device root declares `routeros_system_user`, `routeros_system_user_sshkeys`, `routeros_ip_service` or `routeros_ip_address` (type names verified against the 1.99 provider schema via `tofu providers schema`). Scans root .tf only - the module's www-ssl binding (day 2, #64) stays legal. Verified both ways: clean roots pass, an planted `routeros_ip_address`/`routeros_system_user` is caught with a pointer to adoption.md. `task routeros:validate` added too (init -backend=false + validate + fmt per root). - `docs/routeros/adoption.md`: one page in #66 shape - protected set, what roots own, reset-vs-import adoption, `import { to = module.router..., id = "name=bridge" }` recipe. ## Deliberate deviation from the suggested CA data source The routeros provider's `ca_certificate` takes a **file path**, and the tf-routeros role's policy is issue-only (verified on the harness OpenBao: `path "pki-net-caosh/issue/routeros" { capabilities = ["update"] }`), so `data.vault_generic_secret` on `pki-net-caosh/cert/ca` would 403 at plan time - and the verification anchor the proven flow uses is the **lab root**, not the zone CA (`sim/main.tf` passes a root file, `renewal-test.sh` and `lab-router-certs.sh` verify against it; the leaf chains pki-net-caosh → pki-issue → lab root). So `var.lab_root_ca_path` defaults to `/etc/lab-ca/root.crt`, the lab-root-ca configMap the flux-clusters objects mount for the same runner (identical to `VAULT_CACERT`). If we later want a Vault read instead, the tf-routeros policy needs a `read` grant - separate vault/ change, not here. ## Validation (no devices touched; registry reachable) - `tofu init -backend=false && tofu validate` → `Success! The configuration is valid.` in all three roots. - `tofu fmt -check -recursive` → clean in all three. - Guard: OK clean / FAIL planted (exit 1). - No `tofu plan`/`apply` anywhere; lab untouched. ## Open questions (for the coordinator) 1. Bootstrap mgmt-address collision: the module creates `vlan10-mgmt`/`vlan1001-legacy-mgmt` + addresses 10.30.10.2/.3, 10.16.1.61/.62. The #64 renderer must not put its day-1 address under one of those names/addresses (or bench prep removes it first) - documented in adoption.md. 2. crs309 www-ssl cert day-2 rotation has no owner yet (vault provider pinned there for exactly that). 3. The `routeros-secrets` KV (`routeros-secrets/RB5009_{A,B}_PASSWORD`, `CRS309_PASSWORD`, `PPPOE_{A,B}_{USER,PASSWORD}`) must be seeded before un-suspending; ESO `routeros-*-vars` stay NotReady until then (flux-clusters PR). 4. PPPoE defaults: roots plan without a PPPoE client until credentials arrive (#46/#73).
Author
Owner

Lab verification pass run from workstation (2026-11-16): routeros:guard OK; both roots planned against live lab routers (r1 172.31.254.11, r2 .12, boot state, admin creds since #64 bootstrap has not run there yet): pure creates, 168 to add / 0 change / 0 destroy, no errors. Workstation plan recipe: scratch copy + override.tf nulling module.router tls (vault provider cannot configure outside the runner pod) + serviceaccount_token_path pointed at a dummy file (provider block evaluates file() even with all vault resources count=0 - worth knowing for bench docs). One env note: OpenTofu 1.13.9 returns exit 2 for a changes-present plan from -detailed-exitcode with zero diagnostics; empty plan gives 0. adoption.md's gate (expect exit 0) stays correct, just do not interpret 2 as an error. lab:router-check step 1 (REST over lab root) green on both; steps 2-7 red exactly for the day-2 config these roots own, as expected pre-apply (#74). Nothing merged, no apply performed.

Lab verification pass run from workstation (2026-11-16): routeros:guard OK; both roots planned against live lab routers (r1 172.31.254.11, r2 .12, boot state, admin creds since #64 bootstrap has not run there yet): pure creates, 168 to add / 0 change / 0 destroy, no errors. Workstation plan recipe: scratch copy + override.tf nulling module.router tls (vault provider cannot configure outside the runner pod) + serviceaccount_token_path pointed at a dummy file (provider block evaluates file() even with all vault resources count=0 - worth knowing for bench docs). One env note: OpenTofu 1.13.9 returns exit 2 for a changes-present plan from -detailed-exitcode with zero diagnostics; empty plan gives 0. adoption.md's gate (expect exit 0) stays correct, just do not interpret 2 as an error. lab:router-check step 1 (REST over lab root) green on both; steps 2-7 red exactly for the day-2 config these roots own, as expected pre-apply (#74). Nothing merged, no apply performed.
ginjiruu merged commit a44d352976 into master 2026-11-16 21:04:10 +00:00
Sign in to join this conversation.
No reviewers
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!111
No description provided.