Created
September 10, 2014 19:44
-
-
Save tsantero/9e24d5969b618492b7e6 to your computer and use it in GitHub Desktop.
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/bash | |
set +e | |
declare -i RESULT=0 | |
GIT_DIFF_CMD="git diff HEAD~1 --name-only" | |
# Don't exit on error. Collect the errors instead. | |
YAML_PATH_LIST=`$GIT_DIFF_CMD |grep .yml` | |
# Check YAML files for syntax errors | |
echo 'YAML files to check syntax:'; echo "$YAML_PATH_LIST"; echo ""; | |
for YAML_PATH in $YAML_PATH_LIST; do | |
ansible-playbook -i inventory --syntax-check ../${YAML_PATH}; | |
RESULT+=$? | |
done | |
echo $RESULT "errors." | |
exit $RESULT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment