← All insightsAutomation

Automating HashiCorp Vault from scratch

CodeWizard Academy · 6 April 2026 · 3 min read · Intermediate

Anything you do to HashiCorp Vault twice should be automated. This walks the path from a manual install to a repeatable, pipeline-driven setup.

1. Install it reproducibly

bash
docker run --cap-add=IPC_LOCK -p 8200:8200 -e VAULT_DEV_ROOT_TOKEN_ID=root hashicorp/vault
export VAULT_ADDR=http://127.0.0.1:8200 VAULT_TOKEN=root
vault status

2. Describe the desired state

Enable KV, write a secret, and define a least-privilege policy.

bash
vault secrets enable -path=secret kv-v2
vault kv put secret/app/db password=s3cr3t

cat <<EOF | vault policy write app -
path "secret/data/app/*" { capabilities = ["read"] }
EOF

3. Run it from CI

Pull a secret in CI with the Vault CLI (auth via OIDC/JWT).

yaml
- run: |
    export VAULT_TOKEN=$(vault write -field=token auth/jwt/login role=ci jwt=$CI_JOB_JWT)
    export DB_PASS=$(vault kv get -field=password secret/app/db)

Want senior help putting HashiCorp Vault to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult