Files
terraform-netbox/modules/netbox/variables.tf
T
unkin-agent be53170557
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/plan Pipeline failed
Derive the site from the config path and split out global objects
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

122 lines
3.7 KiB
Terraform

variable "site_slug" {
description = "NetBox site slug, derived from the config path (config/<region>/<dc>); the dc IS the slug."
type = string
}
variable "site" {
description = "Site-wide attributes. `name` defaults to the slug."
type = object({
name = optional(string)
description = optional(string, "")
})
default = {}
}
variable "subnets" {
description = <<-EOT
Map of subnets keyed by name (config file basename,
net-<a>-<b>-<c>-<d>-<len>). Every subnet belongs to this unit's site.
`dhcp` records the pool as a NetBox ip_range only; the DHCP server itself is
the kea-operator's KeaSubnet CRs in argocd-apps. `dns`, `domain` and
`next_server` are not read by any resource here -- they are retained so a
later change can drive Kea from this repo without re-deriving them.
EOT
type = map(object({
prefix = string
description = optional(string, "")
router = optional(number)
dhcp = optional(object({
enabled = optional(bool, true)
start = number
stop = number
}))
dns = optional(list(string), [])
domain = optional(string)
next_server = optional(string)
}))
default = {}
}
variable "vlans" {
description = <<-EOT
This site's VLANs. The site gets one NetBox VLAN group scoped to it, so the
same VID may exist in more than one site.
EOT
type = object({
vid_ranges = optional(list(list(number)), [[1, 4094]])
vlans = optional(list(object({
vid = number
name = string
description = optional(string, "")
})), [])
})
default = {}
}
variable "network_profiles" {
description = <<-EOT
Network profiles keyed by profile name. A profile describes the interfaces a
logical host should have: one entry per interface, each bound to a VLAN VID
and a subnet key, optionally with subinterfaces. Published as a NetBox
config context scoped to this site (and `roles`, if given) so the UI reads
profiles from the NetBox API.
EOT
type = map(object({
description = optional(string, "")
roles = optional(list(string), [])
weight = optional(number, 1000)
interfaces = list(object({
name = string
vlan = number
subnet = string
subinterfaces = optional(list(object({
name = string
vlan = number
subnet = optional(string)
})), [])
}))
}))
default = {}
}
variable "managed_ips" {
description = "Manually managed extra IP addresses (full CIDR form, e.g. 198.18.15.5/24)."
type = list(object({
ip = string
description = optional(string, "")
}))
default = []
}
variable "network_devices" {
description = <<-EOT
Network equipment keyed by device name, all of it in this unit's site.
Switches are declared here rather than left to autodiscovery: nothing probes
one, and its interface templates must be instantiated in NetBox before
discovery can cable a host interface to a port. `device_type` and `role`
name global objects created by the netbox-global unit. `chassis_mac` is
published as the chassis_mac custom field so an LLDP neighbour can be
matched without its SysName.
EOT
type = map(object({
device_type = string
role = string
serial = optional(string)
asset_tag = optional(string)
chassis_mac = optional(string)
}))
default = {}
}
variable "vault_address" {
description = "Vault server address for the token data source."
type = string
default = "https://vault.service.consul:8200"
}
variable "netbox_server_url" {
description = "NetBox server base URL."
type = string
default = "https://netbox.k8s.syd1.au.unkin.net"
}