Files
terraform-netbox/modules/netbox/custom_fields.tf
T
unkin-agent d7c05b00ac
ci/woodpecker/pr/plan Pipeline failed
ci/woodpecker/pr/pre-commit Pipeline was successful
Initial terraform-netbox: NetBox prefixes, devices, platforms, custom fields
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

28 lines
1.0 KiB
Terraform

# Custom-field DEFINITIONS and platforms: the two things bootapi needs NetBox to
# carry before it can pick anything but the default distro.
#
# Definitions only. Values are set where they are owned:
# provision_template -> here, on the device (stable intent)
# pxe_enabled -> NOT managed here. It is runtime state: bootapi's
# /provisioned callback clears it at the end of an
# install so a host does not re-image on its next PXE.
# Setting it from terraform would re-enable installs on
# every apply.
resource "netbox_custom_field" "this" {
for_each = var.custom_fields
name = each.key
type = each.value.type
content_types = each.value.content_types
label = each.value.label
description = each.value.description
}
# A device's platform slug is bootapi's primary distro-catalog selector.
resource "netbox_platform" "this" {
for_each = local.platforms
name = each.value
slug = each.value
}