add vault standalone script

This commit is contained in:
vincent 2022-06-06 09:18:58 +02:00
parent 6e4bc8929d
commit c71722cbab
2 changed files with 38 additions and 1 deletions

View File

@ -1,4 +1,11 @@
dev:
nomad-dev:
@read -p 'enter your vault token:' VAULT_TOKEN;\
nomad agent -dev -bind 0.0.0.0 -dc homelab -vault-address "http://active.vault.service.consul:8200" -vault-create-from-role "nomad-cluster" -vault-enabled -vault-token $$VAULT_TOKEN
vault-dev:
if [ -z "$(FILE)"]; then \
./vault/standalone_vault.sh; \
else \
./vault/standalone_vault.sh $(FILE);\
fi

30
vault/standalone_vault.sh Executable file
View File

@ -0,0 +1,30 @@
CONSUL_HTTP_ADDR=http://127.0.0.1:8500
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 "
vault server -config "/tmp/standalone-vault-dev.hcl"