routeros: full-config render + round-trip gate (#70) #117
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lab/iac!117
Loading…
Reference in a new issue
No description provided.
Delete branch "routeros-generator-70"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #70. Rebased onto master
48bd585(#118-#123). The runner side (provider mirror CLI config, hostAliases) is already on lab/clusters main via #1704.What
routeros/render/turns each device root into one full RouterOS config and proves Terraform adopts it cleanly. The mission is hardware replacement: a dead router or switch gets reimaged on the bench with exactly the config its root describes, and the controller adopts it without creating or breaking anything. The #73 cutover uses the same procedure.task render:device DEVICE=...: fresh CHR with the device's port names, the real #64 bootstrap,tofu applyof a copy of the root (sim exception: own containerlab net 172.31.250.0/24, local state, endpoint validated),/export, cut to what Terraform owns ->out/<device>.full.rsc(gitignored, holds the PPPoE password when rendered with it). Import blocks keyedfield=value->imports/<device>.tf(committed, adoption-time only, never left in a root). Keys are always attributes Terraform holds, never RouterOS auto-names.task render:gate DEVICE=...: fresh CHR, bootstrap, render viaload.sh(the bench loader), empty state + imports, plan. Every object must import with no change, except a fixed allowlist with exact actions:move_itemsx2 create,ip_dnscreate, the www-ssl rotation (module.www_certvault cert, routeros cert, ip_service create limited to numbers/port/certificate/disabled), and the #74 fuse steps (arm, guard, confirm). The residue is applied, and the device export (normalised) must stay identical. The second plan must exit 0. Coverage: no object in a Terraform-owned menu outside state.task render:selftest: the gate must reject five broken renders (missing object, drifted attribute, swapped rules, rogue rule, recovery left on).task render:provider-check: upstream 1.99.1 must fail an in-place address update (vrf bug), the lab fork must apply it.Results (CHR 7.25.1, master
48bd585+ this branch, provider fork 1.99.1003, fresh CHR per step)Selftest: 5/5 broken renders rejected, each for its own reason. Provider check: PASS. The #74 fuse runs in every sim apply: with no probe up it reports NOT ARMED and leaves nothing on the device (
render.shrefuses to export otherwise).Changes outside routeros/render
modules/router: interface list members get"<list>: <interface>"comments, their import key. The in-icmp v6 rule comment loses its commas.crs309/switch.tf: same for the legacy-lan VLAN comment. Comment-only.modules/sitereservation VLAN 10 crs309 -> 10.30.10.10 on a fixed, locally administered bridge MAC02:00:0A:1E:0A:0A(in config, so a replacement switch gets the same lease); the crs309 root getsvlan10-mgmtwith a DHCP client.routeros/tofu.rcinstallsterraform-routeros/routerosfrom the lab fork1.99.1003(public OCI mirrorgit.animeteamspeak.moe/lab/terraform-provider-routeros); the four routeros lock files pin it. Carried fixes, all hit by these CHR applies: vrf read-only on ip_address (upstream PR #984), netwatchtype = "dns"(the #74 DNS probe failed every plan), no default for BGP connectionadd_path_out/address_families(RouterOS 7.21+ rejects both; every #118 BGP connection create failed).bootstrap/render.sh:RENDER_VARS,RENDER_OUT,EXTRA_IP_SANShooks for the sim. Unset changes nothing.Decisions (2026-11-16)
move_items,ip_dns, the vault cert andterraform_datahave no importer.Not provable on a CHR
load.shover the real recovery port, the crs309's DHCP lease (no DHCP server on the CHR's VLAN 10), BGP sessions, and an armed fuse (isolated CHR: NOT ARMED). Bench recipe inrouteros/render/README.md.Pushed
29c7892: the roots now run the lab provider fork 1.99.1+lab.1 (vrf fix, upstream PR #984) from the public OCI mirror git.animeteamspeak.moe/lab/terraform-provider-routeros, via routeros/tofu.rc. task render:provider-check proves it on a CHR (upstream fails the in-place address update with unknown parameter vrf, the fork applies it). All three gates re-run on the fork: PASS, import blocks unchanged.Merge order: lab/clusters #1703 first (runner CLI config); without it the runners cannot resolve 1.99.1+lab.1.
Pushed
0bbecbc, option B for the crs309 management path: site reservation VLAN 10 crs309 -> 10.30.10.10 on a fixed, locally administered bridge MAC (02:00:0A:1E:0A:0A, set in config so a replacement switch gets the same lease); crs309 gets vlan10-mgmt with a DHCP client. The generator now only picks import keys Terraform itself holds (the DHCP client had been keyed by a RouterOS auto-name, client2, which differs on hardware). Gates re-run: crs309 17 imported no-op, rb5009-a/b 167 + allowlist, coverage PASS. The lease itself is a bench check. Runner hostAliases (name -> 10.30.10.x until #50 DNS) are in lab/clusters #1703.Heads-up for the #70 session: master moved. #118 (ER-X parity: BGP, NAT, VLAN/reservation trim), #119 (#74 rollback, adds depends_on = [module.rollback] in crs309/switch.tf identity/NTP/bridge blocks and modules/www-cert), and the static crs309 mgmt from #118 is now removed again (user chose your DHCP design). This branch conflicts in routeros/crs309/switch.tf (bridge block: #119 depends_on next to your auto_mac/admin_mac); please rebase and re-run render:all.
For the #70 session: master now has #122 (router host port map: new modules/router var ports, hybrid pvid+tagged; L2-only VLAN 21 added to the bridge VLAN table; rb5009-a/b main.tf ports maps) and #123 (crs309 trunk_ports = sfp1, sfp2, sfp7, sfp8: routers on sfp1/2 per the neighbor tables, mini bond-10g on sfp7/8). Your local HEAD 1a9dfff is based on #121, so renders from it miss the host ports and the CRS309 trunk fix. Please rebase onto
48bd585before the final render:all / gate / load.ginjiruu referenced this pull request2026-11-17 02:12:59 +00:00
0bbecbc003to39a225eec2For the orchestrator notes above: rebased onto
48bd585(#118-#123, port map included) before the final render. Fresh render, gate and selftest on that base all PASS (rb5009-a/b 208 imported no-op + 9 allowlisted, crs309 24 + 3 fuse steps; selftest 5/5; provider-check PASS). The CHR applies found two more provider bugs, both now carried in the fork (1.99.1003): netwatch type dns (the #119 fuse DNS probe) and BGP connection add_path_out/address_families defaults (the #118 BGP). Details in the description. Merging with the go-ahead from the user.Post-merge review (orchestrator), focused on the hardware load and adoption tonight. No blockers. The render, gate and loader match the README, and the README's adoption recipe is the one I'll follow.
Checked and fine:
render.py export2rsc: an allowlist by menu. Only menus that hold Terraform state are kept./ip serviceand/certificateare dropped, soadmin, the cert and www-ssl stay as the bootstrap left them. Anything matching clab orvrf=mgmtis dropped, and a managed/interface ethernetmenu is a hard fail instead of a silent leak of the sim renames.ip_servicecreate may touch only four attributes. Anything else fails.load.sh: the last line must be the recovery-disable line or the load refuses to run. It checks the cert's IP SAN against the bundled CA, reads the result back over the same connection, and compares the firewall order with dynamic rules excluded.tfstate-*routeros*Secrets, all three Terraform objectssuspend: truewithapprovePlan: "". State is empty, so the import blocks will run.routeros-rb5009-{a,b}-vars(ESO, same values the controller uses).Non-blocking notes:
/importstops at the first error and keeps what came before it. A plain re-run then fails on the duplicates. The device stays reachable, because the recovery address is only disabled by the last line, which isn't sent, and ether8/ether1 sit outside the bridge. Recovery is a reset-slot replay (about 60 s, proven on rb5009-a) and a fresh load. One sentence in README step 3 would save the next person the guesswork.imports/*.tffor the next adoption. A comment inmodules/routeror a guard check that the committed imports still resolve against a fresh render would catch it. Low priority, because the gate re-generates them anyway.For the cutover, not this PR: once loaded, both routers claim 10.15.1.1 (VRRP) and serve DHCP on 10.15.1.0/24. The new island (routers plus CRS309) must stay unplugged from the live LAN until the swap. Today mini's 2.5G and 10G links to it have no carrier, so it's isolated.