Pre-commit hooks for working with Ansible
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
454 B

#! /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;' || {
if [ -s "$file" ]; then
echo "ERROR: $file is not encrypted"
has_error=1
else
echo "WARNING: $file is not encrypted but is empty"
fi
}
done
if [ $has_error -eq 1 ] ; then
echo "To ignore, use --no-verify"
fi
exit $has_error