mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-25 16:41:08 +02:00
* Add DR failover scenario to Enos * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-qualities.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-qualities.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-pr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * remove superuser * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> * Update enos/enos-scenario-dr-replication.hcl Co-authored-by: Ryan Cragun <me@ryan.ec> --------- Co-authored-by: Ryan Cragun <me@ryan.ec>
34 lines
1.1 KiB
Bash
34 lines
1.1 KiB
Bash
#!/bin/bash
|
|
## Copyright (c) HashiCorp, Inc.
|
|
# SPDX-License-Identifier: BUSL-1.1
|
|
|
|
set -e
|
|
|
|
[[ -z "${VAULT_INSTALL_DIR}" ]] && fail "VAULT_INSTALL_DIR env variable has not been set"
|
|
[[ -z "${RETRY_INTERVAL}" ]] && fail "RETRY_INTERVAL env variable has not been set"
|
|
[[ -z "${TIMEOUT_SECONDS}" ]] && fail "TIMEOUT_SECONDS env variable has not been set"
|
|
[[ -z "${VAULT_ADDR}" ]] && fail "VAULT_ADDR env variable has not been set"
|
|
[[ -z "${VAULT_TOKEN}" ]] && fail "VAULT_TOKEN env variable has not been set"
|
|
[[ -z "${SECONDARY_PUBLIC_KEY}" ]] && fail "SECONDARY_PUBLIC_KEY env variable has not been set"
|
|
|
|
fail() {
|
|
echo "$1" 1>&2
|
|
exit 1
|
|
}
|
|
|
|
binpath="${VAULT_INSTALL_DIR}"/vault
|
|
test -x "${binpath}" || fail "unable to locate vault binary at ${binpath}"
|
|
|
|
begin_time=$(date +%s)
|
|
end_time=$((begin_time + TIMEOUT_SECONDS))
|
|
while [ "$(date +%s)" -lt "${end_time}" ]; do
|
|
if secondary_token=$(${binpath} write -field token sys/replication/dr/primary/secondary-token id="${VAULT_TOKEN}" secondary_public_key="${SECONDARY_PUBLIC_KEY}"); then
|
|
echo "${secondary_token}"
|
|
exit 0
|
|
fi
|
|
|
|
sleep "${RETRY_INTERVAL}"
|
|
done
|
|
|
|
fail "Timed out trying to generate secondary token"
|