Derive the site from the config path and split out global objects #1

Open
unkin-agent wants to merge 10 commits from benvin/initial-netbox into main
Member

NetBox holds device types, roles, platforms and custom fields globally, yet they were declared per-site, and the site slug was repeated in YAML under a path that already names it. A second region/dc would collide on every global object.

  • Derive the site from config/<region>/<dc>; terragrunt passes site_slug
  • Replace sites.yaml with site.yaml; drop site:/sites: from subnets, network-devices, vlans, network-profiles
  • Move the global catalogue and the dhcp IPAM role to config/global + modules/netbox-global, own unit and state
  • Per-site unit takes the global ids from that unit as dependency outputs
NetBox holds device types, roles, platforms and custom fields globally, yet they were declared per-site, and the site slug was repeated in YAML under a path that already names it. A second region/dc would collide on every global object. - Derive the site from `config/<region>/<dc>`; terragrunt passes `site_slug` - Replace `sites.yaml` with `site.yaml`; drop `site:`/`sites:` from subnets, network-devices, vlans, network-profiles - Move the global catalogue and the dhcp IPAM role to `config/global` + `modules/netbox-global`, own unit and state - Per-site unit takes the global ids from that unit as dependency outputs
unkin-agent added 1 commit 2026-10-03 15:38:14 +10:00
Initial terraform-netbox: NetBox prefixes, devices, platforms, custom fields
ci/woodpecker/pr/plan Pipeline failed
ci/woodpecker/pr/pre-commit Pipeline was successful
d7c05b00ac
Carried over from terraform-infra, scoped to NetBox: Kea is managed by the
kea-operator CRs. Devices carried no platform and NetBox had no custom
fields, so bootapi could only ever render its default template.

- prefixes, DHCP-pool ip_ranges, gateways, networks, devices and the
  PuppetDB backfill script, minus every Kea resource, provider and token
- netbox_custom_field definitions from config/<region>/<dc>/custom-fields.yaml
- netbox_platform per declared platform, set as the device platform_id
- model_hint written to the device provision_template custom field
- state key infra/terraform/netbox, NetBox token from netbox/creds/terraform-netbox

pxe_enabled's value is deliberately unmanaged: it is runtime state that
bootapi's provisioned callback clears.
unkin-agent added 1 commit 2026-10-03 15:40:12 +10:00
Read the minted NetBox credential from the engine's token field
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline failed
4c9bfb0448
The engine returns it as "token"; "netbox_token" does not exist, so the
plan failed with Invalid index before reaching NetBox.
unkin-agent added 1 commit 2026-10-03 15:41:40 +10:00
Create NetBox sites rather than requiring them to pre-exist
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
380fcff20c
The syd1 site does not exist, so the site data source failed the plan.
Sites now follow the same declared-by-reference rule as device roles,
types and manufacturers.
unkin-agent added 1 commit 2026-10-03 17:26:45 +10:00
Recut the module to the NetBox catalogue only
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
efeb148be7
Device records, interfaces, MACs and cabling are written by the
autodiscovery agent, and host names, roles and IP allocation by the UI, so
terraform declaring them fights both owners.

- drop the device, interface, MAC, per-host IP and net:<name> tag resources
- declare sites, device types, roles and platforms in their own config files
- add interface templates per device type and model the Omada SG3429X
- add per-site VLAN groups and VLANs, seeding vid 101 and 201 in syd1
- publish network profiles as site-scoped config contexts
- rename subnets to net-<a>-<b>-<c>-<d>-<len> and restore dns/domain/next_server
unkin-agent changed title from Initial terraform-netbox: NetBox prefixes, devices, platforms, custom fields to Own only the NetBox catalogue 2026-10-03 17:26:59 +10:00
unkin-agent added 1 commit 2026-10-03 17:33:39 +10:00
Add the chassis_mac custom field and drop the switch device type
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
cead6ab2a0
Switches are created by hand in the NetBox UI, so the model and its port
templates have no consumer.
unkin-agent changed title from Own only the NetBox catalogue to Add terraform-netbox: YAML-driven NetBox catalogue 2026-10-03 17:33:56 +10:00
unkin-agent added 1 commit 2026-10-03 18:04:56 +10:00
Declare the switches and their device type
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
f72f55566d
Nothing probes a switch, and its ports must exist in NetBox before discovery
can cable a host interface to one.
unkin-agent added 1 commit 2026-10-03 18:06:15 +10:00
Create the chassis_mac field before the devices that carry it
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
17f9c2b7c7
unkin-agent added 1 commit 2026-10-03 18:34:41 +10:00
Derive the site from the config path and split out global objects
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline failed
be53170557
Stop repeating the site slug inside the YAML: terragrunt passes the dc as
site_slug and site.yaml carries only site-wide attributes. Declare device
types, roles, platforms, custom fields and the dhcp IPAM role once in
config/global via their own unit and state; the per-site unit looks them up
by slug or name.
unkin-agent changed title from Add terraform-netbox: YAML-driven NetBox catalogue to Derive the site from the config path and split out global objects 2026-10-03 18:34:55 +10:00
unkin-agent added 1 commit 2026-10-03 18:39:04 +10:00
Take global object ids from the global unit
ci/woodpecker/pr/plan Pipeline failed
ci/woodpecker/pr/pre-commit Pipeline was successful
a3984bf0cd
A per-site data-source lookup cannot resolve a global object before the global
unit has applied it, which deadlocks the first plan. Pass device-type, device
role and dhcp IPAM role ids as dependency outputs instead, mocked for plan.
unkin-agent added 1 commit 2026-10-03 18:40:09 +10:00
Allow the mocked global ids during init
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
25e5dfd9b3
All checks were successful
ci/woodpecker/pr/pre-commit Pipeline was successful
Required
Details
ci/woodpecker/pr/plan Pipeline was successful
Required
Details
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin benvin/initial-netbox:benvin/initial-netbox
git checkout benvin/initial-netbox
Sign in to join this conversation.