-
-
Save kitsmag/6f52b9888f0e82037585 to your computer and use it in GitHub Desktop.
Ansible vault transparent encryption revisited
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ ! -r '.vault_password' ]; then | |
exit 1 | |
fi | |
tmp=`mktemp` | |
cat > $tmp | |
ansible-vault encrypt $tmp --vault-password-file=.vault_password > /dev/null 2>&1 | |
cat "$tmp" | |
rm $tmp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ ! -r '.vault_password' ]; then | |
exit 1 | |
fi | |
export PAGER='cat' | |
CONTENT=`ansible-vault view "$1" --vault-password-file=.vault_password 2> /dev/null` | |
if grep -q 'ERROR: data is not encrypted' "$CONTENT"; then | |
cat "$1" | |
else | |
echo "$CONTENT" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ ! -r '.vault_password' ]; then | |
exit 1 | |
fi | |
tmp=`mktemp` | |
cat > $tmp | |
export PAGER='cat' | |
CONTENT=`ansible-vault view "$tmp" --vault-password-file=.vault_password 2> /dev/null` | |
if grep -q 'ERROR: data is not encrypted' $CONTENT; then | |
echo "Looks like one file was commited clear text" | |
echo "Please fix this before continuing !" | |
exit 1 | |
else | |
echo $CONTENT | |
fi | |
rm $tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment