diff options
| author | Luke Kanies <luke@madstop.com> | 2007-12-31 14:37:03 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-12-31 14:37:03 -0600 |
| commit | 33e319a8be8e35fbe4a9ecb7e3185453b8239a83 (patch) | |
| tree | 15cb3788a9a3c783463e2cc129a7cf03c77498a0 /lib | |
| parent | 68cde4f1babe3ebf61ffe215c6328faf7818d40f (diff) | |
| download | puppet-33e319a8be8e35fbe4a9ecb7e3185453b8239a83.tar.gz puppet-33e319a8be8e35fbe4a9ecb7e3185453b8239a83.tar.xz puppet-33e319a8be8e35fbe4a9ecb7e3185453b8239a83.zip | |
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')
| -rw-r--r-- | lib/puppet/type/nagios_command.rb | 31 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_contact.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_contactgroup.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_host.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_hostextinfo.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_hostgroup.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_hostgroupescalation.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_service.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_servicedependency.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_serviceescalation.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_serviceextinfo.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/type/nagios_timeperiod.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/util/nagios_maker.rb | 20 |
13 files changed, 53 insertions, 31 deletions
diff --git a/lib/puppet/type/nagios_command.rb b/lib/puppet/type/nagios_command.rb index f366e9d72..0d0e11b17 100644 --- a/lib/puppet/type/nagios_command.rb +++ b/lib/puppet/type/nagios_command.rb @@ -1,30 +1,3 @@ -require 'puppet/external/nagios' -require 'puppet/external/nagios/base' +require 'puppet/util/nagios_maker' -Puppet::Type.newtype(:nagios_command) do - ensurable - - nagtype = Nagios::Base.type(:command) - - raise "No nagios type" unless nagtype - - newparam(nagtype.namevar, :namevar => true) do - desc "The name parameter for Nagios type %s" % nagtype.name - end - - nagtype.parameters.each do |param| - next if param == nagtype.namevar - - newproperty(param) do - desc "Nagios configuration file parameter." - end - end - - newproperty(:target) do - desc 'target' - - defaultto do - resource.class.defaultprovider.default_target - end - end -end +Puppet::Util::NagiosMaker.create_nagios_type :command diff --git a/lib/puppet/type/nagios_contact.rb b/lib/puppet/type/nagios_contact.rb new file mode 100644 index 000000000..d5a1f3cba --- /dev/null +++ b/lib/puppet/type/nagios_contact.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :contact diff --git a/lib/puppet/type/nagios_contactgroup.rb b/lib/puppet/type/nagios_contactgroup.rb new file mode 100644 index 000000000..b8f14c07b --- /dev/null +++ b/lib/puppet/type/nagios_contactgroup.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :contactgroup diff --git a/lib/puppet/type/nagios_host.rb b/lib/puppet/type/nagios_host.rb new file mode 100644 index 000000000..f2e03f6fb --- /dev/null +++ b/lib/puppet/type/nagios_host.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :host diff --git a/lib/puppet/type/nagios_hostextinfo.rb b/lib/puppet/type/nagios_hostextinfo.rb new file mode 100644 index 000000000..da8e08dd8 --- /dev/null +++ b/lib/puppet/type/nagios_hostextinfo.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :hostextinfo diff --git a/lib/puppet/type/nagios_hostgroup.rb b/lib/puppet/type/nagios_hostgroup.rb new file mode 100644 index 000000000..e1943beec --- /dev/null +++ b/lib/puppet/type/nagios_hostgroup.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :hostgroup diff --git a/lib/puppet/type/nagios_hostgroupescalation.rb b/lib/puppet/type/nagios_hostgroupescalation.rb new file mode 100644 index 000000000..21b39f681 --- /dev/null +++ b/lib/puppet/type/nagios_hostgroupescalation.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :hostgroupescalation diff --git a/lib/puppet/type/nagios_service.rb b/lib/puppet/type/nagios_service.rb new file mode 100644 index 000000000..22b987f56 --- /dev/null +++ b/lib/puppet/type/nagios_service.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :service diff --git a/lib/puppet/type/nagios_servicedependency.rb b/lib/puppet/type/nagios_servicedependency.rb new file mode 100644 index 000000000..0e3340c6e --- /dev/null +++ b/lib/puppet/type/nagios_servicedependency.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :servicedependency diff --git a/lib/puppet/type/nagios_serviceescalation.rb b/lib/puppet/type/nagios_serviceescalation.rb new file mode 100644 index 000000000..cb2af1545 --- /dev/null +++ b/lib/puppet/type/nagios_serviceescalation.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :serviceescalation diff --git a/lib/puppet/type/nagios_serviceextinfo.rb b/lib/puppet/type/nagios_serviceextinfo.rb new file mode 100644 index 000000000..6bdc70900 --- /dev/null +++ b/lib/puppet/type/nagios_serviceextinfo.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :serviceextinfo diff --git a/lib/puppet/type/nagios_timeperiod.rb b/lib/puppet/type/nagios_timeperiod.rb new file mode 100644 index 000000000..25a06d3ed --- /dev/null +++ b/lib/puppet/type/nagios_timeperiod.rb @@ -0,0 +1,3 @@ +require 'puppet/util/nagios_maker' + +Puppet::Util::NagiosMaker.create_nagios_type :timeperiod 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 |
