lldpd: run on physicals and expose neighbour topology as the lldp fact #513
Reference in New Issue
Block a user
Delete Branch "benvin/lldpd"
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?
Why
LLDP is the only source of physical switch/port topology in the estate: which switch and which port each machine is cabled to exists nowhere else (not in intent YAML, not in any other fact, not in DHCP/DNS). NetBox needs it to record device interface -> switch/port connections. This installs and enables lldpd on physical hosts and exposes its neighbour data as a structured
lldpfact for the terraform-infra pdbmux backfill to consume (linked issue below).Changes
profiles::lldpd: install thelldpdpackage and enable+start the service (it ships disabled), the service subscribing to the package.hiera_includeinhieradata/virtual/physical.yaml(facts.virtual == 'physical'), mergeduniquewith the commonhiera_include. VMs never receive it.lldpcustom fact (modules/libs/lib/facter/lldp.rb): parselldpctl -f json0into a per-interface map of{neighbor_chassis_name, neighbor_chassis_mac, neighbor_chassis_descr, neighbor_port_id, neighbor_port_descr, vlan_id, vlan_name}, skipping interfaces with no neighbour. Confined to physical Linux hosts that havelldpctland a live lldpd socket; returns an empty hash on any error so it can never break a puppet run.json0 is used because it array-wraps every node regardless of cardinality, so one neighbour and many neighbours parse identically (plain
keyvaluefolds the neighbour SysName into the key path; plainjsoncollapses single-element arrays into objects).Sample fact output (prodnxsr0019, enp1s0)
Consumer
NetBox population of the switch/port cabling is tracked in terraform-infra: unkin/terraform-infra#7 (extend the pdbmux backfill / PR #6 to read this fact and emit the connection).
https://claude.ai/code/session_01JUoARVdmhxKQHyyyp1pxeT
lldpfact