Discovery boot flow for unknown devices → auto-populate NetBox #3
Reference in New Issue
Block a user
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?
Problem
bootapi resolves a PXE-booting machine by MAC/hostname against NetBox and serves
/ipxe; an unknown MAC currently falls through to the fallback iPXE (fallback-shell/fallback-local). So a brand-new machine cannot bootstrap itself into NetBox — a human must pre-create the device + interface MAC (today done transitionally via terraform-infrabootstrap_mac). There is also no source of switch/port topology anywhere in the estate (no LLDP fact in PuppetDB, none in Cobbler); it can only be captured by the machine at boot.Proposal
Add a discovery path to the
/ipxedecision:staged/unprovisioned devices already flowing normally are unaffected. Reuse the existing NetBox-miss branch + gate/metrics (bootapi_netbox_lookups_total{result=miss},ipxeGated).%pre-style stage, collects hardware reality:dmidecode→ system serial, product name/model, UUID, board, chassis type (asset tag if type-3 populated — usually blank on these OptiPlex).ip -j link), name + MAC + link state. Never assumeenp2s0: interface names vary by model (OptiPlex 3060 enumerates its onboard NIC asenp1s0, 3050/7080 asenp2s0) — key on MAC / lowest-numbered physical NIC.lldpd/lldpctl -f json→ switch chassis-id/sysname + port. This is the only way to obtain topology and is the highest-value new capability.POST /discover): match to an existing declared device by primary MAC or serial; if matched, populate reality (create real interfaces +netbox_mac_addressobjects, replace the transitionalbootstrapinterface, set primary IP, record serial/UUID/inventory, store LLDP neighbour as a cable/connection or a custom field). If unmatched, create aninventory/stageddevice for a human to adopt. bootapi owns the NetBox write (it already holds NetBox creds); the discovery image only POSTs collected JSON.Acceptance
/ipxeserves the discovery chain (not the fallback); covered by a test.bootstrapinterface.enp1s0case).Cross-refs
%precollection script + catalog entry (companion issue).bootstrap_maconce discovery lands; NetBox stays IP/interface-authoritative.Companion: unkin/bootapi-templates#5 (discovery iPXE + %pre template). Also tracks the terraform-infra transitional bootstrap_mac retirement.