From 0186421fc635b3e30b4d4619ef3b9287954c82ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christer=20War=C3=A9n?= Date: Sat, 23 Nov 2024 07:18:17 +0200 Subject: [PATCH] Get Ansible vault passwords in Infra command --- src/commands/infra.sh | 15 +++++++++++++++ wx | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/commands/infra.sh b/src/commands/infra.sh index b7b07de..ce55260 100644 --- a/src/commands/infra.sh +++ b/src/commands/infra.sh @@ -21,6 +21,21 @@ wx-infra(){ fi fi + if [[ ! -f "$INFRA_PATH/vault/cwchristerw" || ! -f "$INFRA_PATH/vault/warengroup" ]] + then + mkdir -p "$INFRA_PATH/vault" &> /dev/null + + curl \ + -H "X-Vault-Token: ${config["login",$ORG]}" \ + -X GET \ + https://$VAULT_DOMAIN/v1/cli/data/cwchristerw/settings/infra -s | jq -r '.data.data.cwchristerw' > "$INFRA_PATH/vault/cwchristerw" + + curl \ + -H "X-Vault-Token: ${config["login",$ORG]}" \ + -X GET \ + https://$VAULT_DOMAIN/v1/cli/data/cwchristerw/settings/infra -s | jq -r '.data.data.warenroup' > "$INFRA_PATH/vault/warengroup" + fi + if [[ -z $1 ]] then echo "Tag Required" diff --git a/wx b/wx index c195db6..9f178d0 100755 --- a/wx +++ b/wx @@ -154,6 +154,21 @@ wx-infra(){ fi fi + if [[ ! -f "$INFRA_PATH/vault/cwchristerw" || ! -f "$INFRA_PATH/vault/warengroup" ]] + then + mkdir -p "$INFRA_PATH/vault" &> /dev/null + + curl \ + -H "X-Vault-Token: ${config["login",$ORG]}" \ + -X GET \ + https://$VAULT_DOMAIN/v1/cli/data/cwchristerw/settings/infra -s | jq -r '.data.data.cwchristerw' > "$INFRA_PATH/vault/cwchristerw" + + curl \ + -H "X-Vault-Token: ${config["login",$ORG]}" \ + -X GET \ + https://$VAULT_DOMAIN/v1/cli/data/cwchristerw/settings/infra -s | jq -r '.data.data.warenroup' > "$INFRA_PATH/vault/warengroup" + fi + if [[ -z $1 ]] then echo "Tag Required"