Vault in Production & OpenBao
Dev mode skips everything that makes Vault safe to run. This lesson starts a Vault the production way (persistent storage, a sealed start, Shamir unseal, an audit device, a snapshot), still offline and on one node, and then lists what a real cluster adds.
A real server, step by step
mkdir -p data
cat > vault.hcl <<'HCL'
storage "raft" { # integrated storage: no external database or Consul
path = "./data"
node_id = "vault-1"
}
listener "tcp" {
address = "127.0.0.1:8200"
tls_disable = true # lab only: production listeners use TLS
}
api_addr = "http://127.0.0.1:8200"
cluster_addr = "http://127.0.0.1:8201"
disable_mlock = true # recommended with integrated storage; disable or encrypt swap instead
HCL
vault server -config=vault.hcl > server.log 2>&1 &
for i in $(seq 50); do vault status > /dev/null 2>&1; [ $? -ne 1 ] && break; sleep 0.2; done # exit 2 = sealed
vault status -format=json | jq -c '{initialized, sealed}'
# init: 5 key shares, 3 needed. In real life each share goes to a different person, PGP-encrypted (-pgp-keys)
vault operator init -key-shares=5 -key-threshold=3 -format=json > init.json
jq -c '{shares: (.unseal_keys_b64 | length), threshold: .unseal_threshold}' init.json
for k in 0 2 4; do # three different key holders
vault operator unseal -format=json $(jq -r ".unseal_keys_b64[$k]" init.json) | jq -c '{sealed, progress}'
done
export VAULT_TOKEN=$(jq -r .root_token init.json)
for i in $(seq 50); do vault secrets list > /dev/null 2>&1 && break; sleep 0.2; done
vault audit enable file file_path=$PWD/audit.log
vault secrets enable -path=secret kv-v2
vault kv put -mount=secret linkly/db password='c0rrect-h0rse' > /dev/null
echo "plain password in the audit log: $(grep -c c0rrect-h0rse audit.log) times"
echo "what is logged instead: $(jq -r 'select(.type == "request" and .request.path == "secret/data/linkly/db") | .request.data.data.password' audit.log | cut -c1-5)…"
vault operator raft list-peers -format=json | jq -c '.data.config.servers[] | {node_id, leader, voter}'
vault operator raft snapshot save backup.snap && echo "snapshot written: $(test -s backup.snap && echo yes)"
vault operator seal
vault status -format=json | jq -c '{sealed}'{"initialized":false,"sealed":true}
{"shares":5,"threshold":3}
{"sealed":true,"progress":1}
{"sealed":true,"progress":2}
{"sealed":false,"progress":0}
Success! Enabled the file audit device at: file/
Success! Enabled the kv-v2 secrets engine at: secret/
plain password in the audit log: 0 times
what is logged instead: hmac-…
{"node_id":"vault-1","leader":true,"voter":true}
snapshot written: yes
Success! Vault is sealed.
{"sealed":true}
- A fresh server is uninitialised and sealed.
operator initcreates the root key, splits it, and returns the shares and an initial root token, once. - Unsealing needed three different shares;
progresscounts them. - The audit log records every request, but secret values are HMAC-ed (
hmac-sha256:…), so the log can be shipped to a SIEM. You can still check whether a known value was accessed withsys/audit-hash. operator sealis the emergency brake: a sealed Vault serves nothing until it is unsealed again.
Note: after
init, revoke the initial root token (vault token revoke -self) once you have set up auth methods and admin policies, and store the unseal shares (or recovery keys) with separate people.
What a production cluster adds
| Concern | Practice |
|---|---|
| High availability | 3 or 5 nodes with integrated storage (Raft quorum); one active node, standbys forward requests; retry_join stanzas so nodes find each other |
| Auto-unseal | seal "awskms" { kms_key_id = "…" } (or azurekeyvault, gcpckms, transit, pkcs11): restarts need no humans; Shamir shares become recovery keys |
| TLS everywhere | listener certificates from your internal CA; clients verify with VAULT_CACERT |
| Backups | scheduled vault operator raft snapshot save (Enterprise has automated snapshots); test restores |
| Audit | at least two audit devices (file + socket/syslog): Vault refuses requests if it can't write to any audit device |
| Monitoring | /v1/sys/health for load balancers; telemetry (telemetry { prometheus_retention_time = "24h" }, then /v1/sys/metrics?format=prometheus) for dashboards; alert on sealed nodes, leadership changes, audit failures, lease counts |
| Configuration as code | auth methods, policies, mounts and roles managed with the Terraform Vault provider, reviewed in pull requests |
| Upgrades | read the important-changes page first; upgrade standbys, then step down the active node |
| Kubernetes | the official Helm chart (hashicorp/vault) in HA Raft mode, with the Agent Injector or VSO |
A sketch of a production server stanza with auto-unseal and TLS:
storage "raft" {
path = "/opt/vault/data"
node_id = "vault-1"
retry_join { leader_api_addr = "https://vault-2.acme.internal:8200" }
retry_join { leader_api_addr = "https://vault-3.acme.internal:8200" }
}
listener "tcp" {
address = "0.0.0.0:8200"
tls_cert_file = "/opt/vault/tls/vault.crt"
tls_key_file = "/opt/vault/tls/vault.key"
}
seal "awskms" {
region = "eu-west-1"
kms_key_id = "alias/vault-unseal"
}
api_addr = "https://vault-1.acme.internal:8200"
cluster_addr = "https://vault-1.acme.internal:8201"
disable_mlock = true
telemetry {
prometheus_retention_time = "24h"
disable_hostname = true
}Managed options
HCP Vault Dedicated (HashiCorp's hosted service) removes the operating work. Cloud-native secret managers (AWS Secrets Manager, Azure Key Vault, Google Secret Manager) cover static secrets and rotation for their own cloud; they are compared in the Toolkit.
OpenBao
OpenBao is the open-source fork of Vault hosted by the Linux Foundation, created after Vault moved to the BUSL license. Practical facts:
- CLI
bao, serverbao server, environment variablesBAO_ADDR/BAO_TOKEN; API paths and response shapes match Vault's, so most clients, Vault Agent-style templates and the Terraform Vault provider work against it. - It forked from the last MPL release (Vault 1.14), so features HashiCorp added later (including the 2.x changes in this course) may be missing or implemented differently, and OpenBao has its own additions. Compare the release notes of the exact versions before migrating.
- Some enterprise-only Vault features have open-source equivalents in OpenBao; others don't exist there. OpenTofu's state encryption supports OpenBao as a key provider (OpenTofu State Encryption).
Choose with the same criteria as the Terraform/OpenTofu choice: license requirements, needed features, support contracts and the ecosystem you already run.
Test yourself
What does vault operator init -key-shares=5 -key-threshold=3 produce?
- 5 root tokens
- 5 unseal key shares (any 3 unseal) and an initial root token
- 3 Raft nodes
- A TLS certificate
How do secret values appear in Vault's audit log?
- In plain text
- HMAC-ed, so the log is safe to ship but known values can still be checked
- Base64-encoded
- They are omitted with no trace
What changes when Vault uses auto-unseal with a cloud KMS?
- Vault no longer encrypts data
- Restarts unseal automatically through the KMS; the Shamir shares become recovery keys
- Policies are disabled
- Audit logs are stored in the KMS