Created
December 4, 2019 02:31
-
-
Save freyes/87b479797f426d0f47a99ada85467e7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export VAULT_ADDR="http://`juju run --unit vault/0 unit-get private-address`:8200" | |
VAULT_INIT="$(vault operator init -key-shares=3 -key-threshold=3)" | |
for KEY in $(echo $VAULT_INIT | grep "Unseal Key " | cut -d' ' -f4); do | |
vault operator unseal $KEY | |
done | |
export VAULT_TOKEN=$(echo $VAULT_INIT | grep "Initial Root Token: " | awk '{print $4}') | |
MY_TOKEN=$(vault token create -ttl=10m | grep "token " | awk '{print $2}') | |
juju run-action --wait vault/leader authorize-charm token=$MY_TOKEN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is this other script that allows you to do the same and it's maintained - https://github.com/canonical/stsstack-bundles/blob/main/tools/vault-unseal-and-authorise.sh