This addresses Redmine ticket #4020.

Currently, the Nagios types default to :array_matching=>:first.  That
is a problem if you want to have, say, multiple systems in a
hostgroup.  This patch will enable array_matching=>:all, along with
the requisite helper functions for file verification.  This patch is
against Puppet 0.25.5.

--- puppet-0.25.5/lib/puppet/util/nagios_maker.rb       Thu Aug 26
13:14:52 2010
+++ /var/opt/webstack/ruby/1.8/gem_home/gems/puppet-0.25.5/lib/puppet/
util/nagios_maker.rb      Thu Aug 26 13:22:56 2010
@@ -27,10 +27,49 @@
             # supported.
             next if param.to_s =~ /^[0-9]/

-            type.newproperty(param) do
-                desc "Nagios configuration file parameter."
+           type.newproperty(param, :array_matching => :all) do
+               desc "Nagios array-capable configuration file
parameter."
+               def change_to_s(currentvalue, newvalue)
+                   currentvalue = currentvalue.join(",") if
currentvalue != :absent and currentvalue.is_a?(Array)
+                   currentvalue = currentvalue.to_s() if
currentvalue.is_a?(Symbol)
+                   newvalue = newvalue.join(",") if newvalue.is_a?
(Array)
+                   newvalue = newvalue.to_s() if newvalue.is_a?
(Symbol)
+                   super(currentvalue, newvalue)
             end
+
+               def is_to_s(value)
+                   if value.is_a?(Array)
+                       if value.include?(:absent)
+                           super
+                       else
+                           super(value.join(','))
         end
+                   else
+                       super(value.to_s())
+                   end
+               end
+
+               def should_to_s(value)
+                   if value.is_a?(Array)
+                       if value.include?(:absent)
+                           super
+                       else
+                           super(value.join(','))
+                       end
+                   else
+                       super(value.to_s())
+                   end
+               end
+
+               def insync?(is)
+                   if defined? @should and @should
+                       self.is_to_s(is) == self.should_to_s(@should)
+                   else
+                       false
+                   end
+               end
+           end
+       end

         type.newproperty(:target) do
             desc 'target'

-- 
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