-
-
Save jetpks/bb27791d5c5f8dd26b3b to your computer and use it in GitHub Desktop.
Validate your puppet manifests and erb templates.
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 | |
# Colors first, because they're important | |
green="\e[0;32m" | |
yellow="\e[1;33m" | |
red="\e[0;31m" | |
norm="\e[0m" | |
if [ ! -e $1 ]; then | |
printf "${yellow}404 NOTFOUND${norm}\t %s\n" $1; | |
exit 404; | |
fi | |
case ${1: -3} in | |
'erb') | |
if cat $1 | erb -x -T - | ruby -c > /dev/null; then | |
printf "${green}200 OK${norm}\t\t %s\n" $1; | |
exit 0; | |
else | |
printf "${red}500 BROKEN${norm}\t %s\n" $1; | |
exit 500; | |
fi | |
;; | |
'.pp') | |
if puppet parser --verbose validate $1; then | |
printf "${green}200 OK${norm}\t\t %s\n" $1; | |
exit 0; | |
else | |
printf "${red}500 BROKEN${norm}\t %s\n" $1; | |
exit 500; | |
fi | |
;; | |
*) | |
printf "${yellow}418 HTCPCP${norm}\t %s\n" $1; #rfc2324 | |
exit 418; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment