forked from RedHatEMEA/acme-soe
-
Notifications
You must be signed in to change notification settings - Fork 3
/
puppet-test
executable file
·74 lines (65 loc) · 1.25 KB
/
puppet-test
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash -x
#
# Local development puppet runs
#
usage()
{
cat <<EOF
Usage: $0 --m|--modulepath MODULEPATH -c|--class CLASS -p|--params YAMLPARAMS -h|--help
MODULEPATH = Path to Puppet modules
CLASS = The Puppet class to apply
YAMLPARAMS = A YAML Hiera file containing class parameters
EOF
}
get_args()
{
ARGS=$(getopt -o m:c:p:h -l "modulepath:class:params:help" -n "$0" -- "$@")
#Bad arguments
if [ $? -ne 0 ]
then
usage
exit 1
fi
eval set -- "$ARGS";
while true; do
case "$1" in
-m|--modulepath)
MODULEPATH="$2"
shift 2 ;;
-c|--class)
CLASS="$2";
shift 2 ;;
-p|--params)
YAMLPARAMS="$2";
shift 2 ;;
-h|--help)
usage
exit 0 ;;
--)
shift
break ;;
esac
done
}
puppet_apply()
{
puppet apply -v --hiera_config $HIERADIR/hiera.yaml --modulepath=$MODULEPATH -e "include $CLASS"
}
create_hiera()
{
export HIERADIR=$(mktemp -d)
cp $YAMLPARAMS $HIERADIR/test.yaml
cat > $HIERADIR/hiera.yaml <<EOF
---
:logger: console
:backends:
- yaml
:yaml:
:datadir: $HIERADIR
:hierachy:
- test
EOF
}
get_args $@
create_hiera
puppet_apply