I am writing a puppet function that will query the stored configs to get a
list of hosts that subscribe to a resource. I have a standalone ruby script
that works and I've "converted" it to a puppet function but it doesn't seem
to be working. I don't see any errors, I just don't get the list of hosts.
Also I am just learning ruby. Does anyone have any suggestions or ideas or
is there another way to already do this?
Thanks
Len
## manifest
class cluster {
$nodes = clustermembership('testcluster')
}
## Function Code
require "puppet"
require "puppet/rails"
module Puppet::Parser::Functions
newfunction(:clustermembership, :type => :rvalue ) do |args|
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:database => 'puppet',
:host => 'localhost',
:password => 'default',
:username => 'puppet'
)
theCluster = args[0]
class Hosts < Puppet::Rails::Host; end
printtype = "name"
query = "( resources.restype = \'File\' AND resources.title =
\'/var/lib/pacemaker/cib/" + theCluster + "-cib.xml\')"
Hosts.find(:all,
:include => [ :resources ],
:conditions => query
).map { |host| host.send(printtype) }
end # newfunction
end # module
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-dev/-/50vNUYCrc9gJ.
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.