RouterOS 004: Import strategy for live devices; singleton rules #66
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lab/iac#66
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 004 (docs/routeros/tracker in this repo history). Research notes: docs/routeros/notes/.
Rules for getting config under management that already exists on a device,
and for objects Terraform cannot fully own. Findings in note §2 (all
verified in provider source).
Import mechanics
terraform import(andimport {}blocks) resolve bynameorfield=value, not just*hexids (providerImportStateCustomContext).For the bench flow prefer writing config + import blocks over
importCLIby hand; it's repeatable for the third device.
imported. Terraform's graph must not contain them (protected set, #002).
Singleton rules
/ip dns,/ip service,/system identity,/snmp,*_settingsmenus...) cannot be deleted over the API; provider delete onlydrops state. Consequences: never expect
destroyto revert them; deleting amanaged singleton from config = removing it from state, leaving the device
attribute set. Manage deliberately, document each in the tree.
default routes on live bench devices): either import and manage, or remove
by hand during bench prep, so
planstarts truthful.Done when
command, and a one-page "adopt a previously hand-configured device" recipe.
Done. Convention + recipe live: docs/routeros/adoption.md (protected set = bootstrap-owned mgmt/www-ssl/users, never in graph) and the render gate carries the per-device import allowlist as the record of what was imported. Proven end-to-end three times at adoption: crs309 (15 imports), rb5009-a/b (166-167 imports + 6 allowlisted), all adopted with plan clean and no drift (iac#129-133). Provider import idiom: one unique field=value.