Report abuse

#!/usr/bin/env ruby
#
# Magical rubyness
#

require 'puppet'
require 'yaml'

Puppet[:config] = "/etc/puppet/puppet.conf"
Puppet.parse_config

pm_conf = Puppet.settings.instance_variable_get(:@values)[:main]

pm_conf.each do |k, v|
   print k
   print ": "
   print v
   print "\n"
end

print "puppetlast\n"

Dir.chdir(pm_conf[:vardir] + "/yaml/facts")

Dir.glob("*.yaml").each do |yaml|
   File.open(yaml).each do |yf|
      fact = YAML::load(yf)
      fact.each do |fact|
         puts fact
      end
   end
   puts host
end

## root@junglist:~# ./test.rb
## vardir: /var/lib/puppet
## ssldir: /var/lib/puppet/ssl
## factpath: /var/lib/puppet/lib/facter
## logdir: /var/log/puppet
## _meta: vardirssldirfactpathlogdirrundir
## rundir: /var/run/puppet
## puppetlast
## ./test.rb:28: undefined method `each' for # (NoMethodError)
##        from ./test.rb:26:in `each'
##        from ./test.rb:26
##        from ./test.rb:25:in `each'
##        from ./test.rb:25