Skip to content

Instantly share code, notes, and snippets.

@pezhore
Last active May 11, 2021
Embed
What would you like to do?
# This little bit of magic is great
# It will run a simple script that pulls vars from vault
echo -n "Vault Password: "
read -s PW
echo ""
LVT=$(curl -ks --request POST --data "{\"password\": \"$PW\"}" https://localhost:8200/v1/auth/userpass/login/pez | jq -r '.auth.client_token')
echo "LVT: [ $LVT ]"
curl -ks --header "X-Vault-Token: $LVT" https://localhost:8200/v1/kv/data/zshrc | jq -r '.data.data | to_entries | .[] | .key + "=" + .value' | while read i; do
export "$i"
done
unset PW
@TheSp1der

This comment has been minimized.

Copy link

@TheSp1der TheSp1der commented May 11, 2021

I have an updated POSIX compatible version that includes a but more sanity. It also addresses an issue with attempting to expose variables from within a while loop.

vault-integration.sh

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