mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 03:27:01 +02:00
Update our `proxy` and `agent` scenarios to support new variants and perform baseline verification and their scenario specific verification. We integrate these updated scenarios into the pipeline by adding them to artifact samples. We've also improved the reliability of the `autopilot` and `replication` scenarios by refactoring our IP address gathering. Previously, we'd ask vault for the primary IP address and use some Terraform logic to determine followers. The leader IP address gathering script was also implicitly responsible for ensuring that a found leader was within a given group of hosts, and thus waiting for a given cluster to have a leader, and also for doing some arithmetic and outputting `replication` specific output data. We've broken these responsibilities into individual modules, improved their error messages, and fixed various races and bugs, including: * Fix a race between creating the file audit device and installing and starting vault in the `replication` scenario. * Fix how we determine our leader and follower IP addresses. We now query vault instead of a prior implementation that inferred the followers and sometimes did not allow all nodes to be an expected leader. * Fix a bug where we'd always always fail on the first wrong condition in the `vault_verify_performance_replication` module. We also performed some maintenance tasks on Enos scenarios byupdating our references from `oss` to `ce` to handle the naming and license changes. We also enabled `shellcheck` linting for enos module scripts. * Rename `oss` to `ce` for license and naming changes. * Convert template enos scripts to scripts that take environment variables. * Add `shellcheck` linting for enos module scripts. * Add additional `backend` and `seal` support to `proxy` and `agent` scenarios. * Update scenarios to include all baseline verification. * Add `proxy` and `agent` scenarios to artifact samples. * Remove IP address verification from the `vault_get_cluster_ips` modules and implement a new `vault_wait_for_leader` module. * Determine follower IP addresses by querying vault in the `vault_get_cluster_ips` module. * Move replication specific behavior out of the `vault_get_cluster_ips` module and into it's own `replication_data` module. * Extend initial version support for the `upgrade` and `autopilot` scenarios. We also discovered an issue with undo_logs that has been described in the VAULT-20259. As such, we've disabled the undo_logs check until it has been fixed. Signed-off-by: Ryan Cragun <me@ryan.ec>
88 lines
2.1 KiB
Bash
88 lines
2.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Copyright (c) HashiCorp, Inc.
|
|
# SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
|
set -e
|
|
|
|
binpath=${VAULT_INSTALL_DIR}/vault
|
|
|
|
fail() {
|
|
echo "$1" 1>&2
|
|
return 1
|
|
}
|
|
|
|
test -x "$binpath" || fail "unable to locate vault binary at $binpath"
|
|
|
|
export VAULT_ADDR='http://127.0.0.1:8200'
|
|
[[ -z "$VAULT_TOKEN" ]] && fail "VAULT_TOKEN env variable has not been set"
|
|
|
|
# If approle was already enabled, disable it as we're about to re-enable it (the || true is so we don't fail if it doesn't already exist)
|
|
$binpath auth disable approle || true
|
|
|
|
$binpath auth enable approle
|
|
|
|
$binpath write auth/approle/role/proxy-role secret_id_ttl=700h token_num_uses=1000 token_ttl=600h token_max_ttl=700h secret_id_num_uses=1000
|
|
|
|
ROLEID=$($binpath read --format=json auth/approle/role/proxy-role/role-id | jq -r '.data.role_id')
|
|
|
|
if [[ "$ROLEID" == '' ]]; then
|
|
fail "expected ROLEID to be nonempty, but it is empty"
|
|
fi
|
|
|
|
SECRETID=$($binpath write -f --format=json auth/approle/role/proxy-role/secret-id | jq -r '.data.secret_id')
|
|
|
|
if [[ "$SECRETID" == '' ]]; then
|
|
fail "expected SECRETID to be nonempty, but it is empty"
|
|
fi
|
|
|
|
echo "$ROLEID" > /tmp/role-id
|
|
echo "$SECRETID" > /tmp/secret-id
|
|
|
|
# Write the Vault Proxy's configuration to /tmp/vault-proxy.hcl
|
|
# The Proxy references the fixed Vault server address of http://127.0.0.1:8200
|
|
# The Proxy itself listens at the address http://127.0.0.1:8100
|
|
cat > /tmp/vault-proxy.hcl <<- EOM
|
|
pid_file = "${VAULT_PROXY_PIDFILE}"
|
|
|
|
vault {
|
|
address = "http://127.0.0.1:8200"
|
|
tls_skip_verify = true
|
|
retry {
|
|
num_retries = 10
|
|
}
|
|
}
|
|
|
|
api_proxy {
|
|
enforce_consistency = "always"
|
|
use_auto_auth_token = true
|
|
}
|
|
|
|
listener "tcp" {
|
|
address = "${VAULT_PROXY_ADDRESS}"
|
|
tls_disable = true
|
|
}
|
|
|
|
auto_auth {
|
|
method {
|
|
type = "approle"
|
|
config = {
|
|
role_id_file_path = "/tmp/role-id"
|
|
secret_id_file_path = "/tmp/secret-id"
|
|
}
|
|
}
|
|
sink {
|
|
type = "file"
|
|
config = {
|
|
path = "/tmp/token"
|
|
}
|
|
}
|
|
}
|
|
EOM
|
|
|
|
# If Proxy is still running from a previous run, kill it
|
|
pkill -F "${VAULT_PROXY_PIDFILE}" || true
|
|
|
|
# Run proxy in the background
|
|
$binpath proxy -config=/tmp/vault-proxy.hcl > /tmp/proxy-logs.txt 2>&1 &
|