On Sat, Dec 25, 2010 at 9:09 PM, James Turnbull <[email protected]>wrote:

> Hi all
>
> I'm trying to retrieve all the currently stored nodes and their facts
> from stored configuration and I am confused about how to approach it.
>
> I have code like:
>
> require 'puppet'
> require 'puppet/rails'
>
> Puppet::Rails.connect
> Puppet::Rails::Host.find(:all).each do |node|
>
> stuff here ...
>
>
try this one:

#!/usr/bin/ruby

require 'puppet'
require 'puppet/rails'

Puppet[:config] = "/tmp/puppet.conf"
Puppet.parse_config
Puppet[:railslog] = "/tmp/rails.log"
Puppet::Rails.connect

Host = Puppet::Rails::Host

Host.all.each do |h|
  puts "facts for #{h.name}"

  h.get_facts_hash.each do |k,v|
    puts "#{k}:\t\t#{v.first.value}"
  end
end

If you need anything more sophisticated, let me know :)

Ohad

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to