-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_puppet_module.sh
executable file
·56 lines (44 loc) · 1.02 KB
/
create_puppet_module.sh
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
#!/bin/bash
EXPECTED_ARGS=1
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` [modulename]"
exit
fi
if [ -d $1 ]
then
echo "ERROR: $1 is a directory. For safety, exiting, as it would destroy data if I ran again."
exit
fi
mkdir -p $1/{depends,files,manifests,templates,test}
echo -e "Basic README for $1\nTest in this directory by running [sudo] ./test/run.sh [noop|reallyrun]" > $1/README
echo -e "class $1 {\n\n}" > $1/manifests/init.pp
echo -e "include \"$1\"" > $1/test/init.pp
# inline script. Done in a subshell to prevent variable expansion
(
cat <<'EOF'
#!/bin/bash
EXPECTED_ARGS=1
if [ $# -ne $EXPECTED_ARGS ]
then
echo "Usage: `basename $0` [noop|reallyrun]"
exit
fi
NOOP="--noop"
if [ "$1" = "reallyrun" ]
then
NOOP=""
fi
PWD=`pwd`
MODULEPATH="$PWD/.."
LIBDIR=""
if [ -d $PWD/plugins ]
then
LIBDIR="--libdir $PWD/plugins"
fi
echo "MODULEPATH: $MODULEPATH LIBDIR: $LIBDIR"
puppet $NOOP -d --modulepath=$MODULEPATH $LIBDIR test/init.pp
exit 0
EOF
) > $1/test/run.sh
chmod 755 $1/test/run.sh