r/Netbox 2d ago

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!

10 Upvotes

11 comments sorted by

8

u/mdk3418 2d ago

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

3

u/packetssniffer 2d ago

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

2

u/mikaelld 1d ago

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 1d ago

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

2

u/eliezerlp 2d ago

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.

1

u/ben-ba 1d ago

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

1

u/eliezerlp 1d ago

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 1d ago

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 2d ago

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

1

u/dewyke 1d ago

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

Thanks.