Backfill NetBox reality from pdbmux #6
Reference in New Issue
Block a user
Delete Branch "benvin/pdbmux-backfill"
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 #1.
Automates the PuppetDB reality backfill into NetBox. Per the issue's latest
comment this queries pdbmux (the PuppetDB multiplexer) rather than PuppetDB
directly: pdbmux merges the old (Consul) and new (k8s) PuppetDBs, needs no auth,
and its HTTPS gateway (
pdbmux.k8s.syd1.au.unkin.net) is reachable fromCI/workstations — the reachability gap that blocked the original in-cluster-only
script. The agreed design is a generator producing reviewable committed output,
not a live data source or CronJob.
Changes:
tools/backfill(Go, no external deps): queries pdbmux/pdb/query/v4/factsfor prodnxsr0001-0013 and emits per-host reality —serial/model/UUID, every recordable interface (real NICs plus
overlay/loopback/kube-lb) with MAC and CIDR IPs, and CPU/RAM/disk inventory.
virtual interfaces only when they carry a routable address (drops the ephemeral
Calico
cali*veths andlo, keepsflannel.1/kube-lb0/loopback*); skipCeph RBD and other virtual block devices; take interface names from Facter,
never assume them.
config/au/syd1/reality/<host>.yaml, generated for all 13 existing physicals.modules/infra: add arealityvariable andreality.tfcreatingnetbox_device_interface/netbox_mac_address/netbox_ip_address/netbox_inventory_itemand the deviceserial. Reality wires into NetBox onlyfor hosts that also have an intent
devices/<host>.yaml.reality/*.yamlin the terragrunt env; addmake backfill; add ago vet/go testwoodpecker job; remove the in-cluster-only Python script.Validation:
go vet+go test -racegreen (mock-pdbmux httptest, real captured factfixture, golden emit, mask/filter cases).
tofu validateonmodules/infrasucceeds; therealityvariable type-checksagainst all 13 generated files and the
reality.tflocals produce the expectedinterface/MAC/IP/inventory maps under the intent guard.
Dependencies / notes:
benvin/initial-infra; PR #5 (which introduces this repo's module andlayout) is not yet merged. Rebase onto
mainonce #5 lands.host's
reality/*.yamlis committed and reviewed but produces no NetBoxresources (guarded by intent presence). No reboots required (acceptance).
https://claude.ai/code/session_01JUoARVdmhxKQHyyyp1pxeT
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.