Skip to content

Instantly share code, notes, and snippets.

@jetpks
Created June 27, 2014 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jetpks/bb27791d5c5f8dd26b3b to your computer and use it in GitHub Desktop.
Save jetpks/bb27791d5c5f8dd26b3b to your computer and use it in GitHub Desktop.
Validate your puppet manifests and erb templates.
#!/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