Add two ansible helpers
This commit is contained in:
parent
b33f7bd2fa
commit
bcb98b9e9a
2 changed files with 109 additions and 0 deletions
28
bin/ansible-vault-show-inline
Executable file
28
bin/ansible-vault-show-inline
Executable 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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue