Files
terraform-netbox/modules/netbox/variables.tf
T
unkin-agent f72f55566d
ci/woodpecker/pr/plan Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
Declare the switches and their device type
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

171 lines
5.1 KiB
Terraform

variable "sites" {
description = "NetBox sites keyed by slug."
type = map(object({
name = string
description = optional(string, "")
}))
default = {}
}
variable "subnets" {
description = <<-EOT
Map of subnets keyed by name (config file basename,
net-<a>-<b>-<c>-<d>-<len>). `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, "")
site = 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 "device_types" {
description = <<-EOT
Device-type catalogue keyed by NetBox slug. `ports` declares interface
templates as ranges: each block names `count` ports from `first`, formatted
with `name_format` (a single %d). NetBox instantiates them on every device
created from the type. Manufacturers are created from the distinct
`manufacturer` values.
EOT
type = map(object({
manufacturer = string
model = string
u_height = optional(number, 1)
ports = optional(list(object({
name_format = string
type = string
first = optional(number, 1)
count = number
mgmt_only = optional(bool, false)
})), [])
}))
default = {}
}
variable "device_roles" {
description = "NetBox device roles keyed by role name; the slug is derived from the name."
type = map(object({
description = optional(string, "")
color_hex = optional(string, "9e9e9e")
}))
default = {}
}
variable "platforms" {
description = "NetBox platforms, slug -> display name. A device's platform slug is bootapi's distro-catalog selector."
type = map(string)
default = {}
}
variable "vlans" {
description = <<-EOT
VLANs keyed by site slug. Each site gets one NetBox VLAN group scoped to the
site, so the same VID may exist in more than one site.
EOT
type = map(object({
vid_ranges = optional(list(list(number)), [[1, 4094]])
vlans = 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 `sites` (and `roles`, if given) so the UI reads
profiles from the NetBox API.
EOT
type = map(object({
description = optional(string, "")
sites = list(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 "custom_fields" {
description = <<-EOT
NetBox custom-field definitions keyed by field name. These are the field
DEFINITIONS only; values are set per device by the owning service.
`content_types` are NetBox "app_label.model" strings, e.g. "dcim.device".
EOT
type = map(object({
type = optional(string, "text")
content_types = list(string)
label = optional(string)
description = optional(string)
}))
default = {}
}
variable "network_devices" {
description = <<-EOT
Network equipment keyed by device name. 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. `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
site = 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"
}