homelab/terraform/vault/standalone_vault.sh

35 lines
784 B
Bash
Raw Permalink Normal View History

2022-06-06 07:18:58 +00:00
CONSUL_HTTP_ADDR=http://127.0.0.1:8500
2022-06-08 19:49:38 +00:00
ANSIBLE_POLICY="ansible"
2022-06-06 07:18:58 +00:00
echo "launch consul dev server"
nohup consul agent -dev &
if [ "$1" ]; then
echo "restore snapshot $1"
sleep 5
consul snapshot restore -http-addr=$CONSUL_HTTP_ADDR $1
fi
tee /tmp/standalone-vault-dev.hcl << EOF
storage "consul" {
address = "127.0.0.1:8500"
path = "vault"
}
listener "tcp" {
address = "0.0.0.0:8200"
tls_disable = 1
}
ui= true
EOF
echo "starting vault server please unseal before use "
2022-06-08 19:49:38 +00:00
nohup vault server -config "/tmp/standalone-vault-dev.hcl" &
vault operator unseal
OTP=$(vault operator generate-root -init|grep "OTP"|head -1|awk '{print $2}')
ENCODE_ROOT=$(vault operator generate-root|tail -1|awk '{print $3}')
vault operator generate-root -decode=$ENCODE_ROOT -otp=$OTP