[tekwalk] [puppet] quick PuppetMaster Service Script
@ tekwalk.blogspot.com [25-April-2012]
http://tekwalk.blogspot.in/2012/04/quick-puppetmaster-service-script-for.html
#!/usr/bin/env rubymodule PuppetMasterdef self.puppetmaster_cmd’puppet master –debug –verbose’enddef self.startputs “Starting Puppet Master in Debug+Verbose+Daemon mode logging to /var/log/puppet/a.log”puts “Started.” if system(“#{puppetmaster_cmd} >> /var/log/puppet/a.log”)enddef self.stoppuppet_master_ps = %x{ps aux | grep -e ‘#{puppetmaster_cmd}’ | grep -v grep}puppet_master_pid = puppet_master_ps.split[1]if system(“kill -9 #{puppet_master_pid}”)puts “PuppetMaster with pid:#{puppet_master_pid} has been killed.”elseputs “Failure killing PuppetMaster with pid:#{puppet_master_pid}.”endenddef self.statuspuppet_master_ps = %x{ps aux | grep -e ‘#{puppetmaster_cmd}’ | grep -v grep}puppet_master_pid = puppet_master_ps.split[1]if puppet_master_pid.nil?puts “No PuppetMaster found.”elseputs “Running @ #{puppet_master_ps}”endendendcase ARGV.firstwhen ‘start’PuppetMaster.startwhen ‘stop’PuppetMaster.stopwhen ‘restart’PuppetMaster.stopPuppetMaster.startwhen ‘status’PuppetMaster.statuselseputs <<-PMUSAGE$service puppetmaster (start|stop|restart|status)PMUSAGEend