Created
June 6, 2014 15:37
-
-
Save anonymous/8e962cedea294a7e56e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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