ansible-pre-commit/encryption-check.sh

22 lines
454 B
Bash
Raw Permalink Normal View History

2017-12-22 16:39:44 +00:00
#! /bin/bash
# Verifies that files passed in are encrypted
set -e
has_error=0
for file in $@ ; do
head -1 "$file" | grep --quiet '^\$ANSIBLE_VAULT;' || {
2017-12-23 00:01:45 +00:00
if [ -s "$file" ]; then
echo "ERROR: $file is not encrypted"
has_error=1
else
echo "WARNING: $file is not encrypted but is empty"
fi
2017-12-22 16:39:44 +00:00
}
done
2017-12-22 16:49:23 +00:00
if [ $has_error -eq 1 ] ; then
2017-12-22 16:39:44 +00:00
echo "To ignore, use --no-verify"
fi
exit $has_error