RouterOS 007: Boot-script compiler from planned values (route A) #69
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lab/iac#69
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Part of #43
Refs: lab/iac#45
Migrated from router-as-code tracker 007 (docs/routeros/tracker in this repo history). Research notes: docs/routeros/notes/.
The tool that turns Terraform truth into the factory
.rscfor each device,so reset/netinstall lands the device at
plan-equivalent state. Full designin note §5; this issue is the build list.
Components
grep PropResourcePathover the pinned providersource →
resource_type → {menu path, add|set kind, computed fields}.Checked-in generated file, regenerate on provider bump (the bump MR fails
its own diff if the table drifts).
terraform plan -out→terraform show -json→ iterateplanned_values.root_module.resources; drop computed/read-only fields;add k=v ...for managed objects,set [find name=...]for setters ofpre-existing entries; hard-error on any value unknown-at-plan (render
must be total, never a script with holes).
menus, the #005 convention (numbered-comment sort, or place_before
topo-sort — whichever #005 decides).
boot.tmpl= preamble (bootstrap #002 content, cert/NTPwaits budgeted to 120 s, secret injection from vars) + rendered sections +
postscript footer (enable bridge
vlan-filtering=yeslast, same trick thesite renderer used).
task boot-one DEVICE=...,task boot-all, goldencmpagainst
golden/committed renders.Non-negotiables
in the Terraform graph, so the compiler can't emit them anyway — enforce
with a guard that fails on those resource types).
Done when
task boot-allrenders three byte-stable scripts; CI diff on every HCLchange; #008 round-trip green in the pipeline.
Elevated by #73 cutover plan: the rendered full boot .rsc is the cutover artifact (controller sits behind the router being replaced). Not optional.
ADR-0009 (2026-11-14): the boot template no longer self-signs. The renderer fetches the router's
www-sslcert+key from OpenBao (pki-net-caosh/routeros, #85) and embeds/certificate import+ thewww-sslbinding. The render must hard-fail when OpenBao is unreachable (never fall back to self-signed). The output holds a private key: treat it as a secret, keep it out ofgolden/as plaintext (golden diffs use a placeholder for the PEM blocks). Cert objects and thewww-sslcertificate binding move out of the protected set (Terraform renews them), see #64.Status 2026-11-17: the compiler core exists as render.py + render/*.sh + the import gate (#70/#117): planned_values -> ordered /rsc, hard-error on unknowns, secrets injected only at render time, proven on all three devices (209-rule hardware plan PASS, reset-slot replay ~60s). Gaps vs done-when: golden/ byte-stable cmp + CI diff on HCL change not implemented; #008 round-trip not wired into a pipeline. Big chunk done, tail is CI work. ready-for-human to decide if the CI tail is worth keeping open or folds into #71/#72.
Done 2026-11-17 per owner: compiler core shipped (render.py + render/*.sh + import gate + move_items ordering; proven on all three devices, 209-rule plan PASS, reset-slot replay ~60s). Remaining CI tail folds: path-table golden/byte-stable cmp + 'regenerate on provider bump' diff lands with the upgrade flow #71 (it is exactly the provider-bump test); the #008 /export round-trip gate lands with the export backstop #72 (same oracle). Comment here with 'golden'/'round-trip' keywords stays findable from both.
Settled 2026-11-17 (#67/#134, #139): no step-10 numbers in rule comments.
modules/router/firewall.tf). The render reproduces it androuteros_move_itemsenforces it. Neither ever reads a number, so a number would only be a second copy of the order that can drift from the first.[tf:<key>]suffix. It is the import key (comma-free, #70) and, since #139, the Prometheus series label for per-rule counters (mktxpfirewall_filter_total{name="| chain | action | comment"}). So a key never changes once a rule exists. Renaming one splits the rule's history.<chain>: <purpose>) is for humans. Editing it is a comment-only plan (sim step 6), but it also renames the series, so treat it as stable too.move_itemsupdate, every.idkept, no label change (sim step 2).The CI tail stays where the earlier comment put it: the golden/provider-bump test with #71, the round-trip with #72.