Skip to content

Instantly share code, notes, and snippets.

Created June 6, 2014 15:37
Show Gist options
  • Save anonymous/8e962cedea294a7e56e1 to your computer and use it in GitHub Desktop.
Save anonymous/8e962cedea294a7e56e1 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'puppet/rails'
Puppet[:config] = '/etc/puppet/puppet.conf'
Puppet.parse_config
config = Puppet.settings.instance_variable_get(:@values)
master_conf = config[:master]
adapter = master_conf[:dbadapter]
args = {:adapter => adapter.
:log_level => master_conf[:rails_loglevel]}
args[:host] = master_conf[:dbserver]
args[:username] = master_conf[:dbuser]
args[:password] = master_conf[:dbpassword]
args[:database] = master_conf[:dbname]
args[:database] = "puppet" unless not args[:database].to_s.empty?
args[:port] = master_conf[:dbport]
socket = master_conf[:dbsocket]
args[:socket] = socket unless socket.to_s.empty?
ActiveRecord::Base.establish_connection(args)
Puppet::Rails::Host.all.each { |h|
puts '#{h.name}"
}
[jeward@vltpuppet01 ~]$ ./hosts.rb
./hosts.rb:12: syntax error, unexpected tSYMBEG
:log_level => master_conf[:rails_loglevel]}
^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment