Files
terraform-netbox/Makefile
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

38 lines
1.1 KiB
Makefile

.PHONY: init plan apply format pre-commit
VAULT_AUTH_METHOD ?= approle
VAULT_K8S_ROLE ?= woodpecker_terraform_netbox
VAULT_K8S_MOUNT ?= auth/k8s/au/syd1
VAULT_K8S_JWT_PATH ?= /var/run/secrets/kubernetes.io/serviceaccount/token
define vault_env
@export VAULT_ADDR="https://vault.service.consul:8200" && \
if [ "$(VAULT_AUTH_METHOD)" = "kubernetes" ]; then \
export VAULT_TOKEN=$$(vault write -field=token $(VAULT_K8S_MOUNT)/login role=$(VAULT_K8S_ROLE) jwt=$$(cat $(VAULT_K8S_JWT_PATH))); \
else \
export VAULT_TOKEN=$$(vault write -field=token auth/approle/login role_id=$$VAULT_ROLEID); \
fi && \
export CONSUL_HTTP_TOKEN=$$(vault read -field=token consul_root/au/syd1/creds/terraform-netbox)
endef
init:
@$(call vault_env) && \
terragrunt run --all --non-interactive init -- -upgrade
plan: init
@$(call vault_env) && \
terragrunt run --all --parallelism 4 --non-interactive plan
apply: init
@$(call vault_env) && \
terragrunt run --all --parallelism 2 --non-interactive apply
format:
@echo "Formatting OpenTofu files..."
@tofu fmt -recursive .
@echo "Formatting Terragrunt files..."
@terragrunt hcl fmt
pre-commit:
@uvx pre-commit run --all-files