Skip to content

Instantly share code, notes, and snippets.

@abhishekkr
Created April 24, 2012 11:59
Show Gist options
  • Save abhishekkr/2479100 to your computer and use it in GitHub Desktop.
Save abhishekkr/2479100 to your computer and use it in GitHub Desktop.
just a quick PuppetMaster Service Script for gem installed puppet set-up
#!/usr/bin/env ruby
module PuppetMaster
def self.puppetmaster_cmd
'puppet master --debug --verbose'
end
def self.start
puts "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")
end
def self.stop
puppet_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."
else
puts "Failure killing PuppetMaster with pid:#{puppet_master_pid}."
end
end
def self.status
puppet_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."
else
puts "Running @ #{puppet_master_ps}"
end
end
end
case ARGV.first
when 'start'
PuppetMaster.start
when 'stop'
PuppetMaster.stop
when 'restart'
PuppetMaster.stop
PuppetMaster.start
when 'status'
PuppetMaster.status
else
puts <<-PMUSAGE
$service puppetmaster (start|stop|restart|status)
PMUSAGE
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment