Report abuse

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
bash-3.2# cat /usr/bin/puppet_external_nodes.sh 
#!/bin/bash
#
#  Script that checks out the passed hostname and determines the correct classes
#  
#  Hostnames are parsed:  machinename-machinetype-building with either .local or .huronhs.com ending
#
#  If a hostname does not conform to the hyphenated standard, it receives a non-zero error type
#    and is passed back to the nodes.pp file in Puppet.
#

hostname=$1

#  Extract machinename, machinetype, and building codes

one=`echo $hostname | awk -F'-' '{print $1}'`
two=`echo $hostname | awk -F'-' '{print $2}'`
three=`echo $hostname | awk -F'-' '{print $3}' | sed 's/\..*//'`

#  If the machine does not conform to the hyphenated standard, pass a non-zero error
#    and return us to the main nodes.pp file.

if [ -z "$two" ] && [ "${two+xxx}" = "xxx" ]; then
	exit 1
fi

#  If the machine DOES conform to the hyphenated standard, pass the machinetype and
#     building variables as classtypes in Puppet.  Exit 0 to appease Puppet

cat << END
---
classes:
        - general_image
        - $two
        - $three
parameters:
        puppet_server: testing.huronhs.com
END

exit 0