Add two ansible helpers

This commit is contained in:
Lexi / Zoe 2021-05-31 14:25:10 +02:00
parent b33f7bd2fa
commit bcb98b9e9a
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
2 changed files with 109 additions and 0 deletions

28
bin/ansible-vault-show-inline Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
# Strict mode
set -euo pipefail
IFS=$'\n\t'
if [[ $# -eq 0 ]] || [[ $1 == "--help" ]]; then
echo "Usage: $(basename $0) FILE VARIABLE"
echo
echo "Decrypts ansible-vault encrypted inline variable VARIABLE from FILE."
echo
echo "Example: $(basename $0) roles/common/defaults.main.yml user_root_password"
exit 1
elif [[ $# -lt 2 ]]; then
echo "Error: Missing arguments." >&2
exit 1
fi
VAR_FILE=$1
VAR_NAME=$2
if [[ ! -f $VAR_FILE ]]; then
echo "Error: Variable file '$VAR_FILE' does not exist!" >&2
exit 1
fi
ansible localhost -m debug -a "var=$VAR_NAME" -e "@$VAR_FILE"