Added puppet-clean-storeconfigs script
This commit is contained in:
parent
e1ba92e9ef
commit
a1fdae9293
2 changed files with 53 additions and 0 deletions
40
puppet/files/puppet-clean-storeconfigs
Executable file
40
puppet/files/puppet-clean-storeconfigs
Executable 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
|
Loading…
Add table
Add a link
Reference in a new issue