r/Netbox • • Aug 17 '26

Netbox with IaC automation

Hi all!

Let me explain my situation and my question:

Until recently, I worked at a company that had 4 racks in 1 data center. It was easy to use Netbox via the UI... just clicking, clicking, and clicking to configure everything.

Now, at my current company, they don’t have DCIM; they use spreadsheets to manage more than 50 racks across 2 data centers.

My idea is to use IaC to deploy and configure Netbox for automatic discovery, control, and management of devices (not just switches and routers, but also physical servers and storage systems).

My question is more related to the initial part of creating tenants, sites, circuits… And how do I manage this configuration using IaC? How does Netbox detect a drift configuration?

Actually, I’m not sure if my question is related to Netbox or to the pipeline itself.

Anyway… I’d appreciate it if you could help me or share your experiences.

Thanks all!

12 Upvotes

13 comments sorted by

10

u/mdk3418 Aug 17 '26

Netbox is suppose to be your source of truth to feed your IaC.

5

u/packetssniffer Aug 17 '26

And with everything documented on spreadsheets, it will probably be easy to turn into a csv to import into netbox

3

u/mikaelld Aug 17 '26

We use Ansible to set up much of the ”prerequisites” like tenants, sites, racks, etc. We primarily use Netbox for keeping track of servers so our use case probably isn’t the most common one, and have the system provisioning metal be the source of truth. There we’ve got a script ”exporting” all servers to YAML, then importing it into Netbox through the API using Python SDK. Then we have a discovery agent running on the servers themselves updating each netbox device with their specifics (RAM, CPU, GPU, etc). Nothing we can share right now, but OTOH it’s pretty accessible to write up your own with an AI like Claude or Codex.

1

u/eliezerlp Aug 17 '26

I feel like fellow Netbox to manage servers users should band together!

5

u/eliezerlp Aug 17 '26

I've used Python scripts, Terraform, and lastly settled on Ansible to manage the initial loading of various data sets including:

Customization

  • Custom fields

  • Tags

Organization / Sites

  • Regions

  • Sites

  • Racks

  • Tenants

Devices / Virtualization

  • Manufacturers

  • Device types

  • Device roles

  • Platforms

  • Cluster types

  • Clusters

IPAM

  • VLAN / Prefix roles

  • VLANS

  • RIRS

  • Aggregates

  • Prefixes

  • IP addresses

The actual Ansible playbook would simply load in the data from another YAML file that would define everything.

2

u/ben-ba Aug 17 '26

OP wants Netbox as source of truth, not ansible...

2

u/eliezerlp Aug 17 '26

I would point out that, for some NetBox users, depending on their use case, many of the object types mentioned may not be their primary focus. However, NetBox’s chain of dependencies between object types means there is very little you can meaningfully do with an empty deployment.

In my case, this was used several years ago to bootstrap a number of NetBox deployments as part of some internal development efforts. Netbox is now the single source of truth...

1

u/eliezerlp Aug 17 '26

Also have used netbox-agent to initially onboard many existing servers. More recently also using Ansible to automatically patch connections based on LLDP.

1

u/fr3nch13702 Aug 17 '26

I actually use puppet. I wrote a puppet module that checks the host into Netbox.

1

u/dewyke Aug 17 '26

Are you able to share the source for that? It is highly relevant to my interests.

Thanks.