Skip to content

Instantly share code, notes, and snippets.

@pezhore
Last active May 11, 2021 20:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pezhore/209a769920b917de191822ae8bee8984 to your computer and use it in GitHub Desktop.
Save pezhore/209a769920b917de191822ae8bee8984 to your computer and use it in GitHub Desktop.
# 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
Copy link

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