mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-08-07 00:57:00 +02:00
Update to 2023-07-03 15:00
This commit is contained in:
25
roles/vault/templates/update_nomad_cert.j2
Normal file
25
roles/vault/templates/update_nomad_cert.j2
Normal file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
NOMAD_TOKEN=$1
|
||||
VAULT_TOKEN=$2
|
||||
|
||||
VAULT_ADDR={{ vault_conf.api_addr }}
|
||||
|
||||
if [ "$(vault status -format=json | jq .is_self)" != "true" ]; then
|
||||
echo "We're not the active vault, exiting"
|
||||
elif [ "$(vault status -format=json | jq .sealed)" != "false" ]; then
|
||||
echo "Vault is sealed, exiting"
|
||||
elif [ "$(vault status -format=json | jq .initialized)" != "true" ]; then
|
||||
echo "Vault is not initialized yet, exiting"
|
||||
else
|
||||
echo Updating Vault certificate to access Nomad API
|
||||
VAULT_TOKEN=$VAULT_TOKEN \
|
||||
vault write {{ vault_secrets.nomad.secret.path }}/config/access \
|
||||
address="{{ vault_secrets.nomad.address }}" \
|
||||
token="$NOMAD_TOKEN" \
|
||||
ca_cert="$(cat {{ vault_root_dir }}/tls/nomad_ca.crt)" \
|
||||
client_cert="$(cat {{ vault_root_dir }}/tls/nomad_client.crt)" \
|
||||
client_key="$(cat {{ vault_root_dir }}/tls/nomad_client.key)"
|
||||
fi
|
Reference in New Issue
Block a user