Created
October 19, 2016 01:18
-
-
Save e2thenegpii/196838306b5e901bf682e84b8d0dba49 to your computer and use it in GitHub Desktop.
git pre-commit hook to make sure all files with a given filename are encrypted with ansible-vault
This file contains 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/bash | |
encryptedIndicator="$ANSIBLE_VAULT" | |
encryptedFilename="encrypted.yml" | |
sbe=`find $PWD -name $encryptedFilename | sort -u` | |
encrypted=`find $PWD -name $encryptedFilename -exec grep "$encryptedIndicator" {} -l \;| sort -u` | |
shouldbe=`comm -3 <(printf '%s\n' "${sbe[@]}") <(printf '%s\n' "${encrypted[@]}")` | |
if [ ! -z "$shouldbe" -a "$shouldbe" != " " ]; then | |
echo "Please check that the following files are properly encrypted" | |
echo "'$shouldbe'" | |
exit -1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment