2022-01-27 10:08:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-09-30 09:19:55 +00:00
|
|
|
. functions.sh
|
|
|
|
check_juju_version
|
2022-01-27 10:08:00 +00:00
|
|
|
|
2024-09-30 09:19:55 +00:00
|
|
|
get_juju_status
|
2022-01-27 10:08:00 +00:00
|
|
|
|
2024-09-30 09:19:55 +00:00
|
|
|
vault_file="vault-secrets.txt"
|
|
|
|
vault_token_file="vault-token.txt"
|
2022-01-27 10:08:00 +00:00
|
|
|
|
|
|
|
vault operator init -key-shares=5 -key-threshold=3 > ${vault_file}
|
|
|
|
|
2024-09-30 09:19:55 +00:00
|
|
|
do_vault
|
2022-01-27 10:08:00 +00:00
|
|
|
|
|
|
|
initial_token=$(grep Initial ${vault_file} | awk '{print $4}')
|
|
|
|
|
|
|
|
export VAULT_ADDR="http://${vault_vip}:8200"
|
|
|
|
export VAULT_TOKEN=${initial_token}
|
|
|
|
|
|
|
|
vault token create -ttl=10m > ${vault_token_file}
|
|
|
|
|
2024-09-30 09:19:55 +00:00
|
|
|
token=$(grep token ${vault_token_file} | head -n 1 | awk '{print $2}')
|
2022-01-27 10:08:00 +00:00
|
|
|
|
2024-09-30 09:19:55 +00:00
|
|
|
${juju_run_action} vault/leader authorize-charm token=${token}
|