Page MenuHomePhabricator

Improve Netbox PuppetDB import script to set switch trunk port Vlans as needed
Open, LowestPublic


The Puppet DB Netbox import script works very well and, once interfaces are set up on a host, properly adds them in Netbox, and attaches IP objects as needed.

This is true for all interfaces on Linux hosts, including vlan / 802.1q sub-interfaces.

If a host has vlan sub-interfaces, however, the switch port it's connected to needs to be configured as a trunk, usually with the primary interface untagged ("native vlan" on the switch side), and the remaining tagged. Switch configuration is controlled by the port settings in Netbox (for example The port's attributes in Netbox are set so that the "802.1q mode" is "tagged", and the "untagged" and "tagged" vlan fields are populated as needed.

Currently setting the switch port mode and allowed vlans is done manually if required. Which is not a big deal as the number of devices with sub-ints is very low. An improvement could be made by which the Netbox PuppetDB import script would evaluate if tagged sub-interfaces are present, and make sure that the corresponding switch port is configured to match. Likely this would be easier if T296832 was also completed, to properly represent the interface relationships in Netbox, as opposed to evaluating based on names.

Not urgent by any means, but creating task to record the gap that could be filled at some stage.

Event Timeline

cmooney triaged this task as Lowest priority.Dec 15 2021, 1:42 PM
cmooney created this task.

In the current state of our infra I don't think that part should be dynamic.

Switch ports are configured by DCops (or service owners when knowledgeable) at provisioning time and shouldn't change during the server's lifecycle. Special cases are infrequent enough to be changed manually and verifying that the change is expected.

Having that part dynamic I'd worry that:

  • It makes automation more complex by adding new dependencies (DCops says one thing, the server another, who is right?)
  • It creates outstanding and unexpected changes after a server is re-imaged or similar

That said, improving the PuppetDB Netbox report to highlight this kind of discrepancies would be welcome, although not urgent.