Files
terraform-netbox/modules/netbox/devices.tf
unkin-agent a3984bf0cd
ci/woodpecker/pr/plan Pipeline failed
ci/woodpecker/pr/pre-commit Pipeline was successful
Take global object ids from the global unit
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

16 lines
714 B
Terraform

# Network equipment is declared here, unlike host devices: nothing probes a
# switch, and its ports must already exist in NetBox for discovery to cable a
# host interface to one. The device type and role are global objects, created
# by the netbox-global unit.
resource "netbox_device" "network" {
for_each = var.network_devices
name = each.key
device_type_id = var.device_type_ids[each.value.device_type]
role_id = var.device_role_ids[each.value.role]
site_id = tonumber(netbox_site.this.id)
serial = each.value.serial
asset_tag = each.value.asset_tag
custom_fields = each.value.chassis_mac != null ? { chassis_mac = lower(each.value.chassis_mac) } : null
}