-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuppet-pre-commit-hook
More file actions
executable file
·42 lines (40 loc) · 958 Bytes
/
puppet-pre-commit-hook
File metadata and controls
executable file
·42 lines (40 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
#
# basic puppet syntax check
#
for ppfile in `git diff --name-only HEAD~1 | grep "\.pp\|\.erb\|.yaml\|.eyaml"`
do
if [[ -f $ppfile ]]
then
case $ppfile in
*.pp)
puppet parser validate $ppfile
if [[ $? -ne 0 ]]
then
echo "$ppfile not validated by puppet parser"
puppet_syntax=1
else
echo "$ppfile has been validated by puppet parser"
fi ;;
*.erb)
erb -P -x -T '-' "$ppfile" | ruby -c
if [[ $? -ne 0 ]]
then
echo "$ppfile not a valid erb file"
puppet_syntax=1
else
echo "$ppfile is a valid erb file"
fi ;;
*.yaml|*.eyaml)
ruby -r yaml -e "YAML.parse(File.open('${ppfile}'))"
if [[ $? -ne 0 ]]
then
echo -e "ERROR: YAML parse: $ppfile"
puppet_syntax=1
else
echo -e "OK: $ppfile looks valid"
fi ;;
esac
fi
done
exit $puppet_syntax;