From aef0666da8bfaff99559d6424e52fadcdd37cc98 Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Tue, 17 Nov 2026 23:06:43 +1100 Subject: [PATCH] Mint netbox user-management token dynamically (#184) The netbox engine admin token was rotated, so netbox_user_management (still on the static KV admin_token because user_mgmt_username is unset) now fails plan with 403 "Invalid v2 token". The vault-user-mgmt role already exists in Vault. - set user_mgmt_username to admin so user management uses the Vault-minted netbox/creds/vault-user-mgmt token - declare the vault-secrets-netbox provider in the generated root config - import the existing netbox/roles/vault-user-mgmt role into state Reviewed-on: https://git.unkin.net/unkin/terraform-vault/pulls/184 Co-authored-by: unkin-agent Co-committed-by: unkin-agent --- config/netbox_secret_backend/netbox.yaml | 7 +++---- environments/root.hcl | 9 +++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/config/netbox_secret_backend/netbox.yaml b/config/netbox_secret_backend/netbox.yaml index 9c2ff49..f314fbb 100644 --- a/config/netbox_secret_backend/netbox.yaml +++ b/config/netbox_secret_backend/netbox.yaml @@ -42,7 +42,6 @@ description: "NetBox ephemeral scoped API token engine" netbox_url: "https://netbox.k8s.syd1.au.unkin.net" token_version: 2 request_timeout_seconds: 30 -# Set to the pre-existing NetBox superuser admin_token belongs to, to mint the -# user-management credential dynamically (recommended). Until set, user management -# uses admin_token directly and a check block warns that rotation will break it. -# user_mgmt_username: "vault-netbox-admin" +# NetBox superuser the user-management credential is minted for (via +# netbox/roles/vault-user-mgmt), so rotating admin_token does not break it. +user_mgmt_username: "admin" diff --git a/environments/root.hcl b/environments/root.hcl index 0233a7f..b70ad32 100644 --- a/environments/root.hcl +++ b/environments/root.hcl @@ -35,6 +35,11 @@ provider "arrstack" { address = local.vault_addr } +import { + to = module.netbox_user_mgmt_role["netbox"].netbox_secret_backend_role.this + id = "netbox/roles/vault-user-mgmt" +} + terraform { backend "consul" { address = "https://consul.service.consul" @@ -69,6 +74,10 @@ terraform { source = "artifactapi.k8s.syd1.au.unkin.net/terraform-unkin/vault-secrets-arrstack" version = "0.2.0" } + netbox = { + source = "artifactapi.k8s.syd1.au.unkin.net/terraform-unkin/vault-secrets-netbox" + version = "0.1.0" + } } } EOF