If you'd like to run puppetmaster in a mongrel cluster you have to start X
instances of puppetmaster with servertype set to mongrel. With this patch
you can add more than one port to the sysconfig file and puppetmaster will
automatically be started with severtype set to mongrel.
You can now even specify an alternate port in the sysconfig file on which
puppetmaster should be run as webrick based server. See sysconfig file for
more documentation.

This is the second version of this patch and it adresses some comments
which have been made by David Lutterkort on Ticket #1460:

- there's no need to introduce PUPPETMASTER_PID_DIR as a variable in
  sysconfig

removed.

- the way RETVAL is accumulated (RETVAL=$? || $RETVAL) is wrong;
  it needs to be 'ret=$?; [ $ret != 0 ] && RETVAL=$ret'

fixed.

- make sure that 'status' still works and lists all the instances in
  the multiport case (similar to 'service nfs status')

added.

Signed-off-by: duritong <[EMAIL PROTECTED]>
---
 conf/redhat/server.init      |   49 ++++++++++++++++++++++++++++++++++++------
 conf/redhat/server.sysconfig |   22 ++++++++++++++++++
 2 files changed, 64 insertions(+), 7 deletions(-)

diff --git a/conf/redhat/server.init b/conf/redhat/server.init
index 8266977..6871b9a 100644
--- a/conf/redhat/server.init
+++ b/conf/redhat/server.init
@@ -1,7 +1,8 @@
 #!/bin/bash
 # puppetmaster  This shell script enables the puppetmaster server.
 #
-# Author:       Duane Griffin <[EMAIL PROTECTED]>
+# Authors:       Duane Griffin <[EMAIL PROTECTED]>
+#                Peter Meier <[EMAIL PROTECTED]> (Mongrel enhancements)
 #
 # chkconfig: - 65 45
 #
@@ -22,6 +23,11 @@ fi
 
 PUPPETMASTER_OPTS=""
 [ -n "$PUPPETMASTER_MANIFEST" ] && 
PUPPETMASTER_OPTS="--manifest=${PUPPETMASTER_MANIFEST}"
+if [ -n "$PUPPETMASTER_PORTS" ] && [ [EMAIL PROTECTED] -gt 1 ]; then
+    PUPPETMASTER_OPTS="$PUPPETMASTER_OPTS --servertype=mongrel"
+elif [ -n "$PUPPETMASTER_PORTS" ] && [ [EMAIL PROTECTED] -eq 1 ]; then
+    PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} 
--masterport=${PUPPETMASTER_PORTS[0]}" 
+fi
 [ -n "$PUPPETMASTER_LOG" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} 
--logdest=${PUPPETMASTER_LOG}"
 PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} \
        ${PUPPETMASTER_EXTRA_OPTS}"
@@ -36,8 +42,16 @@ start() {
 
        # Confirm the manifest exists
        if [ -r $PUPPETMASTER_MANIFEST ]; then
-               daemon $PUPPETMASTER $PUPPETMASTER_OPTS
-               RETVAL=$?
+        if [ -n "$PUPPETMASTER_PORTS" ] && [ [EMAIL PROTECTED] -gt 1 ]; then
+            for ((i=0; i<[EMAIL PROTECTED]; i++)); do
+                echo -en "\nPort: ${PUPPETMASTER_PORTS[$i]}"
+                daemon $PUPPETMASTER $PUPPETMASTER_OPTS 
--masterport=${PUPPETMASTER_PORTS[$i]} 
--pidfile=/var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid
+                ret=$?; [ $ret != 0 ] && RETVAL=$ret
+            done
+        else
+            daemon $PUPPETMASTER $PUPPETMASTER_OPTS
+            RETVAL=$?
+        fi
        else
                failure $"Manifest does not exist: $PUPPETMASTER_MANIFEST"
                echo
@@ -50,8 +64,16 @@ start() {
 
 stop() {
        echo -n  $"Stopping puppetmaster: "
-       killproc $PUPPETMASTER
-       RETVAL=$?
+    if [ -n "$PUPPETMASTER_PORTS" ] && [ [EMAIL PROTECTED] -gt 1 ]; then
+        for ((i=0; i<[EMAIL PROTECTED]; i++)); do
+            echo -en "\nPort: ${PUPPETMASTER_PORTS[$i]}"
+            killproc -p 
/var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid puppetmaster 
+            ret=$?; [ $ret != 0 ] && RETVAL=$ret
+        done
+    else
+       killproc $PUPPETMASTER
+       RETVAL=$?
+    fi
        echo
        [ $RETVAL -eq 0 ] && rm -f "$lockfile"
        return $RETVAL
@@ -67,6 +89,20 @@ genconfig() {
   $PUPPETMASTER $PUPPETMASTER_OPTS --genconfig
 }
 
+puppetmaster_status() {
+    if [ -n "$PUPPETMASTER_PORTS" ] && [ [EMAIL PROTECTED] -gt 1 ]; then
+        for ((i=0; i<[EMAIL PROTECTED]; i++)); do
+            echo -en "Port ${PUPPETMASTER_PORTS[$i]}: "
+            status -p 
/var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid puppetmaster 
+            ret=$?; [ $ret != 0 ] && RETVAL=$ret
+        done 
+    else
+           status $PUPPETMASTER
+        RETVAL=$?
+    fi
+    return $RETVAL
+}
+
 case "$1" in
   start)
        start
@@ -81,8 +117,7 @@ case "$1" in
        [ -f "$lockfile" ] && restart
        ;;
   status)
-       status $PUPPETMASTER
-        RETVAL=$?
+    puppetmaster_status
        ;;
   genconfig)
        genconfig
diff --git a/conf/redhat/server.sysconfig b/conf/redhat/server.sysconfig
index fe673cc..befb40f 100644
--- a/conf/redhat/server.sysconfig
+++ b/conf/redhat/server.sysconfig
@@ -5,5 +5,27 @@
 # Specify syslog to send log messages to the system log.
 #PUPPETMASTER_LOG=syslog
 
+# You may specify an alternate port or an array of ports on which 
+# puppetmaster should listen. Default is: 8140
+# If you specify more than one port, the puppetmaster ist automatically
+# started with the servertype set to mongrel. This might be interesting
+# if you'd like to run your puppetmaster in a loadbalanced cluster.
+# Please note: this won't setup nor start any loadbalancer. 
+# If you'd like to run puppetmaster with mongrel as servertype but only
+# on one (specified) port, you have to add --servertype=mongrel to
+# PUPPETMASTER_EXTRA_OPTS.
+# Default: Empty (Puppetmaster isn't started with mongrel, nor on a 
+# specific port)
+#
+# Please note: Due to reduced options in the rc-functions lib in RHEL/Centos
+# versions prior to 5, this feature won't work. Fedora versions >= 8 are 
+# known to work.
+#PUPPETMASTER_PORTS=""
+# Puppetmaster on a different port, run with standard webrick servertype
+#PUPPETMASTER_PORTS="8141"
+# Example with multiple ports which will start puppetmaster with mongrel
+# as a servertype
+#PUPPETMASTER_PORTS=( 18140 18141 18142 18143 )
+
 # You may specify other parameters to the puppetmaster here
 #PUPPETMASTER_EXTRA_OPTS=--noca
-- 
1.5.4.3


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to