Added puppet-clean-storeconfigs script

This commit is contained in:
Ossi Salmi 2012-02-02 22:09:35 +02:00
parent e1ba92e9ef
commit a1fdae9293
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,40 @@
#!/usr/bin/env ruby
require 'puppet/rails'
if ARGV[0].nil?
puts "Usage: #{$0} <node>"
exit
end
Puppet[:config] = "/etc/puppet/puppet.conf"
Puppet.parse_config
pm_conf = Puppet.settings.instance_variable_get(:@values)[:master]
adapter = pm_conf[:dbadapter]
args = {:adapter => adapter, :log_level => pm_conf[:rails_loglevel]}
case adapter
when "sqlite3":
args[:database] = pm_conf[:dblocation]
when "mysql", "postgresql":
args[:host] = pm_conf[:dbserver] unless pm_conf[:dbserver].empty?
args[:username] = pm_conf[:dbuser] unless pm_conf[:dbuser].empty?
args[:password] = pm_conf[:dbpassword] unless pm_conf[:dbpassword].empty?
args[:database] = pm_conf[:dbname]
socket = pm_conf[:dbsocket]
args[:socket] = socket unless socket.empty?
else
raise ArgumentError, "Invalid db adapter %s" % adapter
end
ActiveRecord::Base.establish_connection(args)
if @host = Puppet::Rails::Host.find_by_name(ARGV[0].strip)
print "Killing #{ARGV[0]}..."
$stdout.flush
@host.destroy
puts "done."
else
puts "Can't find host #{ARGV[0]}."
end

View file

@ -368,6 +368,19 @@ class puppet::server::common inherits puppet::client {
}
}
if $puppet_storeconfigs != "none" {
file { "/usr/local/sbin/puppet-clean-storeconfigs":
ensure => present,
source => "puppet:///modules/puppet/puppet-clean-storeconfigs",
mode => 0755,
owner => "root",
group => $operatingsystem ? {
openbsd => "wheel",
default => "root",
},
}
}
}