Puppet: System Administration Automated

Support

UsingMongrel: puppetmaster

File puppetmaster, 2.0 kB (added by dissent, 1 year ago)

Sample puppetmasterd with Mongrel init script for Red Hat? systems.

Line 
1 #!/bin/bash
2
3 # Puppet master using Mongrel init script for use on RedHat systems.
4
5 # This script controls all of the process which comprise the Puppet master.
6 # Specifically, an Apache httpd front end configured to reverse proxy to
7 # several Puppetmasters using Mongrel.
8
9 # chkconfig: - 65 45
10
11 export PATH=/usr/bin:/sbin:/bin:/usr/sbin
12
13 # Redhat functions
14 . /etc/rc.d/init.d/functions
15
16 RETVAL=0
17
18 # Run multiple puppetmasters on these ports
19 PUPPETMASTERPORTS="8150 8151 8152 8153 8154"
20
21 # Locking and run stuff
22 RUNDIR=/var/lib/puppet/run
23 LOCKDIR=/var/lock/subsys/
24
25 start() {
26     local daemonargs=' --check $base --pidfile $pidfile'
27
28     for pmp in $PUPPETMASTERPORTS ; do
29         local pmargs="--servertype mongrel --masterport $pmp --pidfile \$pidfile"
30         start_proc puppetmaster-$pmp $daemonargs puppetmasterd $pmargs
31     done
32
33     httpdargs="-f /etc/puppet/httpd.conf"
34     start_proc puppet-httpd $daemonargs httpd $httpdargs
35 }
36
37 start_proc() {
38     local base=$1
39     local pidfile=$RUNDIR/$base.pid
40     local lockfile=$LOCKDIR/$base
41     shift
42
43     echo -n $"Starting $base: "
44
45     eval daemon $*
46     RETVAL=$?
47     [ $RETVAL = 0 ] && touch ${lockfile}
48
49     echo
50     return $RETVAL
51 }
52
53 stop() {
54     stop_proc puppet-httpd
55
56     for pmp in $PUPPETMASTERPORTS ; do
57         stop_proc puppetmaster-$pmp
58     done
59 }
60
61 stop_proc() {
62     local base=$1
63     local pidfile=$RUNDIR/$base.pid
64     local lockfile=$LOCKDIR/$base
65
66         echo -n  $"Stopping $base: "
67
68         killproc -p $pidfile $base
69         RETVAL=$?
70         [ $RETVAL -eq 0 ] && rm -f "$lockfile"
71
72         echo
73         return $RETVAL
74 }
75
76 status_pm() {
77     for pmp in $PUPPETMASTERPORTS ; do
78         status_proc puppetmaster-$pmp
79     done
80
81     status_proc puppet-httpd
82 }
83
84 status_proc() {
85     local base=$1
86     local pidfile=$RUNDIR/$base.pid
87     local lockfile=$LOCKDIR/$base
88
89         status -p $pidfile $base
90 }
91
92 case "$1" in
93   start)
94         start
95         ;;
96
97   stop)
98         stop
99         ;;
100
101   restart|reload|force-reload)
102     stop
103     start
104         ;;
105
106   status)
107         status_pm
108         ;;
109
110   *)
111         echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
112         exit 1
113 esac
114
115 exit $RETVAL