API
curl -X "PUT" "http://[IP]:8200/v1/sys/init" \
-H "Content-Type: text/plain; charset=utf-8" \
-d '{"secret_shares":1, "secret_threshold":1}'
export VAULT_TOKEN=[TOKEN]
CLI
vault init -key-shares=1 -key-threshold=1
export VAULT_TOKEN=[TOKEN]
API
curl -X "PUT" "http://[IP]:8200/v1/sys/unseal" \
-H "Content-Type: text/plain; charset=utf-8" \
-d '{ "key": "KEY"}'
CLI
vault unseal
API
curl -X "POST" "http://[IP]:8200/v1/sys/mounts/redis" \
-H "X-Vault-Token: $VAULT_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d $'{"type": "generic"}'
vault mount -path=redis generic
API
curl -X "POST" "http://[IP]:8200/v1/redis/secret1" \
-H "X-Vault-Token: $VAULT_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d '{"key1": "value1", "key2": "value2"}'
CLI
vault write redis/secret1 key1=value1 key2=value2
API
curl "http://[IP]:8200/v1/redis/secret1" \
-H "X-Vault-Token: $VAULT_TOKEN"
CLI
vault read redis/secret1
API
curl -X "PUT" "http://[IP]:8200/v1/sys/policy/redis" -H "X-Vault-Token: $VAULT_TOKEN" -H "Content-Type: text/plain; charset=utf-8" --data-binary "@files/redis-policy.json"
curl "http://192.168.33.2:8200/v1/sys/policy/redis" -H "X-Vault-Token: $VAULT_TOKEN"
CLI
vault policy-write redis files/redis-policy.hcl
vault read redis/secret1
API
curl -X "PUT" "http://[IP]:8200/v1/sys/policy/nomad-server" -H "X-Vault-Token: $VAULT_TOKEN" -H "Content-Type: text/plain; charset=utf-8" --data-binary "@files/nomad-server-policy.json"
curl "http://192.168.33.2:8200/v1/sys/policy/nomad-server" -H "X-Vault-Token: $VAULT_TOKEN"
CLI
vault policy-write nomad-server nomad-server-policy.hcl
vault policies nomad-server
API
curl -X "PUT" "http://[IP]:8200/v1/auth/token/roles/nomad-cluster" \
-H "X-Vault-Token: $VAULT_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d '{"disallowed_policies": "nomad-server", "explicit_max_ttl": 0, "name": "nomad-cluster", "orphan": false, "period": 259200, "renewable": true}'
curl "http://192.168.33.2:8200/v1/auth/token/roles/nomad-cluster" \
-H "X-Vault-Token: $VAULT_TOKEN"
CLI
vault write /auth/token/roles/nomad-cluster @nomad-cluster-role.json
vault read /auth/token/roles/nomad-cluster
API
curl -X "POST" "http://[IP]:8200/v1/auth/token/create/nomad-cluster" \
-H "X-Vault-Token: $VAULT_TOKEN" \
-H "Content-Type: text/plain; charset=utf-8" \
-d '{"policy": "nomad-server", "period": "72h"}'
CLI
vault token-create -policy nomad-server -period 72h
sudo vi /etc/nomad.d/nomad.hcl (enable & set token)
sudo service nomad restart
nomad run files/redis.nomad
nomad alloc-status
nomad node-status NODE_ID
ssh to the appropriate client (from node-status above)
sudo docker ps
sudo docker exec -i -t [CONTAINER_ID] /bin/bash
echo $VAULT_TOKEN
wget --header "X-Vault-Token: $VAULT_TOKEN" http://[IP]:8200/v1/redis/secret1