Skip to content

Commit 685bbfe

Browse files
devantlerclaude
andcommitted
fix(openbao): declare file audit device in HCL (API enable is blocked)
CI on this branch was failing with: Error enabling audit device: Error making API request. URL: PUT http://openbao.openbao.svc.cluster.local:8200/v1/sys/audit/file Code: 400. Errors: * cannot enable audit device via API; use declarative, config-based audit device management instead OpenBao does not allow enabling the audit device at runtime via the sys/audit API -- it requires the device to be declared in the server's HCL config alongside listener/storage. The vault-config Job's 'bao audit enable' call was therefore wrong by design and would never have worked against this OpenBao build. Fix: 1. openbao HelmRelease (standalone.config): add a declarative audit "file" { file_path = "/openbao/audit/audit.log" } stanza. /openbao/audit is the chart's auditStorage PV mount path (matches the /openbao/data data path). OpenBao reads this on startup; no API call needed. Every API request is logged to /openbao/audit/audit.log as one JSON record per line. 2. vault-config Job: drop the now-dead 'bao audit enable' block. Replace it with a comment explaining why this is declarative-only. Renumber the trailing 'Database secrets engine' section from 8 -> 7 in both the body and the top-of-file step list. The previous commit (1ade5f5) fixed the path from /vault to /openbao based on the chart default; this commit moves the configuration to the correct place (HCL config) so it actually takes effect. Validation: $ ksail workload validate → 256 files validated $ ksail --config ksail.prod.yaml workload validate → 256 files validated Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1ade5f5 commit 685bbfe

2 files changed

Lines changed: 29 additions & 20 deletions

File tree

k8s/bases/infrastructure/controllers/openbao/helm-release.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ spec:
8585
storage "file" {
8686
path = "/openbao/data"
8787
}
88+
89+
# Declarative file audit device on the auditStorage PV. OpenBao
90+
# blocks runtime audit enables: `bao audit enable file …`
91+
# returns "cannot enable audit device via API; use declarative,
92+
# config-based audit device management instead", so the device
93+
# MUST be declared here in HCL. The mount path /openbao/audit
94+
# is the chart's auditStorage default. Every API request is
95+
# written to /openbao/audit/audit.log as one JSON record per
96+
# line; tail it from the openbao pod today, ship via promtail
97+
# once the observability stack lands.
98+
audit "file" {
99+
file_path = "/openbao/audit/audit.log"
100+
}
88101
topologySpreadConstraints:
89102
- maxSkew: 1
90103
topologyKey: kubernetes.io/hostname

k8s/bases/infrastructure/vault-config/job.yaml

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
# 4. Creates least-privilege policies
1212
# 5. Creates auth roles mapping ServiceAccounts to policies
1313
# 6. Configures OIDC auth (Dex) for human admin access
14-
# 7. Enables the file audit device (writes to the auditStorage PV)
15-
# 8. Configures the Database secrets engine for fleetdm MySQL rotation
14+
# 7. Configures the Database secrets engine for fleetdm MySQL rotation
15+
#
16+
# The file audit device is declared in the openbao HelmRelease config
17+
# (declarative-only — OpenBao rejects runtime audit enables via API),
18+
# so no runtime step is needed here for auditing.
1619
#
1720
# On fresh install the init containers auto-initialize the vault and create
1821
# the openbao-unseal Secret. On Velero restore the Secret and PVC are both
@@ -453,24 +456,17 @@ spec:
453456
echo "It will be configured on the next vault-config reconciliation."
454457
fi
455458
456-
# --- 7. Audit device: file backend to the auditStorage PV ---
457-
# OpenBao writes one JSON record per request to /openbao/audit/
458-
# audit.log. That directory is the auditStorage PV mount path
459-
# provisioned by the chart -- /openbao/audit pairs with the
460-
# /openbao/data data mount (the OpenBao chart standardised on
461-
# /openbao/* paths rather than the upstream HashiCorp Vault
462-
# /vault/* paths). Tail this file from the openbao pod, or
463-
# ship it via a sidecar / promtail when the observability
464-
# stack lands. Without this device, OpenBao has zero audit
465-
# trail -- any read of a Secret goes unrecorded.
466-
if ! bao audit list -format=json 2>/dev/null | grep -q '"file/"'; then
467-
echo "Enabling file audit device..."
468-
bao audit enable file file_path=/openbao/audit/audit.log
469-
else
470-
echo "File audit device already enabled."
471-
fi
472-
473-
# --- 8. Database secrets engine: fleetdm MySQL static-role rotation ---
459+
# NOTE: the file audit device used to be enabled here at
460+
# runtime. OpenBao rejects that path -- `bao audit enable`
461+
# returns "cannot enable audit device via API; use
462+
# declarative, config-based audit device management
463+
# instead". The audit device is now declared in the
464+
# openbao HelmRelease's standalone.config HCL (a
465+
# `audit "file" { file_path = "/openbao/audit/audit.log" }`
466+
# stanza alongside listener and storage). No runtime step
467+
# is needed for OpenBao to start auditing.
468+
469+
# --- 7. Database secrets engine: fleetdm MySQL static-role rotation ---
474470
# OpenBao owns and periodically rotates the 'fleet' MySQL user's
475471
# password; ESO reads the current value via the VaultDynamicSecret
476472
# generator in the fleetdm namespace.

0 commit comments

Comments
 (0)