Skip to content

Instantly share code, notes, and snippets.

@freyes
Created December 4, 2019 02:31
Show Gist options
  • Save freyes/87b479797f426d0f47a99ada85467e7f to your computer and use it in GitHub Desktop.
Save freyes/87b479797f426d0f47a99ada85467e7f to your computer and use it in GitHub Desktop.
#!/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
@freyes
Copy link
Author

freyes commented Jun 9, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment