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

10 Commits

Author SHA1 Message Date
unkin-agent 25e5dfd9b3 Allow the mocked global ids during init
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline was successful
2026-10-03 18:40:08 +10:00
unkin-agent a3984bf0cd Take global object ids from the global unit
ci/woodpecker/pr/plan Pipeline failed
ci/woodpecker/pr/pre-commit Pipeline was successful
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.
2026-10-03 18:39:03 +10:00
unkin-agent be53170557 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
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.
2026-10-03 18:34:40 +10:00
unkin-agent 17f9c2b7c7 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
2026-10-03 18:06:07 +10:00
unkin-agent f72f55566d Declare the switches and their device type
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
Nothing probes a switch, and its ports must exist in NetBox before discovery
can cable a host interface to one.
2026-10-03 18:04:52 +10:00
unkin-agent cead6ab2a0 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
Switches are created by hand in the NetBox UI, so the model and its port
templates have no consumer.
2026-10-03 17:33:37 +10:00
unkin-agent efeb148be7 Recut the module to the NetBox catalogue only
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
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
2026-10-03 17:26:43 +10:00
unkin-agent 380fcff20c 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
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.
2026-10-03 15:41:38 +10:00
unkin-agent 4c9bfb0448 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
The engine returns it as "token"; "netbox_token" does not exist, so the
plan failed with Invalid index before reaching NetBox.
2026-10-03 15:40:11 +10:00
unkin-agent d7c05b00ac Initial terraform-netbox: NetBox prefixes, devices, platforms, custom fields
ci/woodpecker/pr/plan Pipeline failed
ci/woodpecker/pr/pre-commit Pipeline was successful
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.
2026-10-03 15:38:02 +10:00