Skip to content

Instantly share code, notes, and snippets.

@kitsmag
Forked from leucos/clean_vault
Last active December 23, 2015 09:45
Show Gist options
  • Save kitsmag/6f52b9888f0e82037585 to your computer and use it in GitHub Desktop.
Save kitsmag/6f52b9888f0e82037585 to your computer and use it in GitHub Desktop.
Ansible vault transparent encryption revisited
#!/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
#!/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
#!/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