Vault Operations
Operational guide for HashiCorp Vault secrets management in the fzymgc-house cluster.
Quick Reference
Section titled “Quick Reference”| Property | Value |
|---|---|
| URL | https://vault.fzymgc.house |
| Auth Methods | OIDC (Keycloak), Token |
| Storage Backend | Integrated Storage (Raft) |
| Terraform Module | tf/vault/ |
| Helper Script | ./scripts/vault-helper.sh |
Secret Structure
Section titled “Secret Structure”All infrastructure secrets stored under secret/fzymgc-house/:
| Path | Purpose |
|---|---|
infrastructure/bmc/tpi-alpha | TuringPi Alpha BMC credentials |
infrastructure/bmc/tpi-beta | TuringPi Beta BMC credentials |
infrastructure/cloudflare/api-token | Cloudflare API token |
cluster/keycloak | Keycloak Terraform/bootstrap admin credentials |
cluster/hcp-terraform | HCP Terraform agent token |
Authentication
Section titled “Authentication”export VAULT_ADDR=https://vault.fzymgc.house
# OIDC login (browser-based)vault login -method=oidc
# Token loginvault loginCommon Operations
Section titled “Common Operations”Read a Secret
Section titled “Read a Secret”vault kv get secret/fzymgc-house/cluster/keycloak
# Get single fieldvault kv get -field=terraform_password secret/fzymgc-house/cluster/keycloakList Secrets
Section titled “List Secrets”vault kv list secret/fzymgc-house/cluster/Write a Secret
Section titled “Write a Secret”vault kv put secret/fzymgc-house/cluster/example key=valueHelper Script Operations
Section titled “Helper Script Operations”# Check connectivity./scripts/vault-helper.sh status
# List infrastructure secrets./scripts/vault-helper.sh list
# Get specific secret./scripts/vault-helper.sh get bmc/tpi-alpha
# Get single field./scripts/vault-helper.sh get bmc/tpi-alpha passwordIntegration Examples
Section titled “Integration Examples”Ansible Integration
Section titled “Ansible Integration”# Vault lookup in group_varstpi_bmc_password: "{{ lookup('community.hashi_vault.vault_kv2_get', 'infrastructure/bmc/tpi-alpha', engine_mount_point='secret/fzymgc-house').secret.password }}"
cloudflare_api_token: "{{ lookup('community.hashi_vault.vault_kv2_get', 'infrastructure/cloudflare/api-token', engine_mount_point='secret/fzymgc-house').secret.token }}"For Ansible modules that access Vault directly, ensure the CA bundle is set
so Python requests can validate TLS. Configure vault_ca_cert_bundle in
ansible/inventory/group_vars/all.yml or set VAULT_CACERT.
Requires community.hashi_vault collection (installed via requirements).
Terraform Integration
Section titled “Terraform Integration”data "vault_kv_secret_v2" "cloudflare" { mount = "secret/fzymgc-house" name = "infrastructure/cloudflare/api-token"}
provider "cloudflare" { api_token = data.vault_kv_secret_v2.cloudflare.data["token"]}Secret Rotation
Section titled “Secret Rotation”Manual Rotation
Section titled “Manual Rotation”- Generate new credential
- Update Vault secret
- Restart affected pods to pick up changes
Automatic Rotation
Section titled “Automatic Rotation”Some secrets support automatic rotation via Vault policies.
Rotating secrets consumed via write-only (*_wo) attributes
Section titled “Rotating secrets consumed via write-only (*_wo) attributes”Some Terraform sinks read Vault secrets ephemerally and write them through
write-only attributes (kubernetes_secret_v1.data_wo,
tfe_notification_configuration.token_wo, …; hl-106s, ADR hl-ujwi). Terraform
cannot diff write-only content, so rotating the Vault secret does not
propagate by itself (exception: the tfe notification url/token use the
provider’s auto-hash mode and re-send automatically).
After rotating such a secret in Vault:
- Find the consuming resource (grep the workspace for
data_wo/ephemeral "vault_kv_secret_v2"). - Increment its
data_wo_revisionby exactly 1 (helm’sset_wo_revisionmust strictly increase; kubernetes accepts any change). - Plan/apply the workspace (
main-cluster-bootstrapis Local execution — apply manually). - Verify the in-cluster value changed
(
kubectl get secret ... -o json | jq -S '.data' | sha256sum).
PKI Certificate Rotation
Section titled “PKI Certificate Rotation”Kubernetes Workloads (VaultDynamicSecret)
Section titled “Kubernetes Workloads (VaultDynamicSecret)”Kubernetes workloads using VaultDynamicSecret automatically rotate PKI certificates:
apiVersion: secrets.hashicorp.com/v1beta1kind: VaultDynamicSecretmetadata: name: router-hosts-client-certspec: mount: fzymgc-house/v1/ica1/v1 path: issue/router-hosts-client destination: name: router-hosts-client-cert create: true renewalPercent: 67The operator renews certificates at 67% of TTL automatically.
CLI Client Certificates
Section titled “CLI Client Certificates”For CLI tools (like router-hosts), certificates must be manually renewed:
# Check certificate expiryopenssl x509 -in ~/.config/router-hosts/tls.crt -text -noout | grep -A2 Validity
# Re-issue certificate (Bash/Zsh)CERT_DATA=$(vault write -format=json fzymgc-house/v1/ica1/v1/issue/router-hosts-client \ common_name="cli-$(whoami)" ttl=720h)echo "$CERT_DATA" | jq -r '.data.certificate' > ~/.config/router-hosts/tls.crtecho "$CERT_DATA" | jq -r '.data.private_key' > ~/.config/router-hosts/tls.keyecho "$CERT_DATA" | jq -r '.data.issuing_ca' > ~/.config/router-hosts/ca.crtAvailable PKI Roles
Section titled “Available PKI Roles”| Role | Mount Path | Purpose | Default TTL |
|---|---|---|---|
router-hosts-client | fzymgc-house/v1/ica1/v1 | gRPC client auth | 720h |
router-hosts-server | fzymgc-house/v1/ica1/v1 | gRPC server cert | 720h |
Required Policy
Section titled “Required Policy”Developers need infrastructure-developer policy. Defined in tf/vault/policy-infrastructure-developer.hcl:
path "secret/data/fzymgc-house/infrastructure/*" { capabilities = ["read", "list"]}path "secret/metadata/fzymgc-house/infrastructure/*" { capabilities = ["list"]}path "secret/data/fzymgc-house/*" { capabilities = ["read", "list"]}path "secret/metadata/fzymgc-house/*" { capabilities = ["list"]}Troubleshooting
Section titled “Troubleshooting”Vault Sealed
Section titled “Vault Sealed”If Vault is sealed, unseal keys are required. Contact cluster admin.
Permission Denied
Section titled “Permission Denied”Check your Vault policy assignments in Keycloak groups.
Connectivity Issues
Section titled “Connectivity Issues”curl -s https://vault.fzymgc.house/v1/sys/healthvault token lookupAnsible Secret Issues
Section titled “Ansible Secret Issues”ansible-galaxy collection list | grep hashi_vaultansible localhost -m debug -a "msg={{ lookup('community.hashi_vault.vault_kv2_get', 'infrastructure/bmc/tpi-alpha', engine_mount_point='secret/fzymgc-house').secret.password }}"Terraform Issues
Section titled “Terraform Issues”vault token lookupterraform console> data.vault_kv_secret_v2.keycloak.dataSee Also
Section titled “See Also”- Secrets Reference
- HCP Terraform Operations - Dynamic credentials