summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-12-31 14:37:03 -0600
committerLuke Kanies <luke@madstop.com>2007-12-31 14:37:03 -0600
commit33e319a8be8e35fbe4a9ecb7e3185453b8239a83 (patch)
tree15cb3788a9a3c783463e2cc129a7cf03c77498a0 /lib/puppet/util
parent68cde4f1babe3ebf61ffe215c6328faf7818d40f (diff)
Added builtin support for all Nagios resource types.
I use Naginator to parse and generate the files, with ParsedFile to handle record management and the like. Note that each resource type itself is just a call to a Factory method, since everything is just based on Naginator. Given that, all of the tests are in a single unit/ral/types/nagios.rb file, since I used a factory to generate them, too. This is probably either unnecessary or insufficient, but it's as far as I'm willing to go in testing them, and it did actually catch a few bugs.
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/nagios_maker.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/puppet/util/nagios_maker.rb b/lib/puppet/util/nagios_maker.rb
index 7c019f55e..f1f85466f 100644
--- a/lib/puppet/util/nagios_maker.rb
+++ b/lib/puppet/util/nagios_maker.rb
@@ -19,9 +19,14 @@ module Puppet::Util::NagiosMaker
desc "The name parameter for Nagios type %s" % nagtype.name
end
- nagtype.parameters.each do |param|
+ # We deduplicate the parameters because it makes sense to allow Naginator to have dupes.
+ nagtype.parameters.uniq.each do |param|
next if param == nagtype.namevar
+ # We can't turn these parameter names into constants, so at least for now they aren't
+ # supported.
+ next if param.to_s =~ /^[0-9]/
+
type.newproperty(param) do
desc "Nagios configuration file parameter."
end
@@ -35,6 +40,17 @@ module Puppet::Util::NagiosMaker
end
end
- type.provide(:naginator, :parent => Puppet::Provider::Naginator, :default_target => "/etc/nagios/#{full_name.to_s}.cfg") {}
+ provider = type.provide(:naginator, :parent => Puppet::Provider::Naginator, :default_target => "/etc/nagios/#{full_name.to_s}.cfg") {}
+
+ type.desc "The Nagios type #{name.to_s}. This resource type is autogenerated using the
+ model developed in Naginator_, and all of the Nagios types are generated using the
+ same code and the same library.
+
+ This type generates Nagios configuration statements in Nagios-parseable configuration
+ files. By default, the statements will be added to ``#{provider.default_target}, but
+ you can send them to a different file by setting their ``target`` attribute.
+
+ .. _naginator: http://reductivelabs.com/trac/naginator
+ "
end
end