Sha256: fa14840bd6eec74fde454702673306ea7dbf889cd5c1489234cfc31b810fa6fb

Contents?: true

Size: 1.97 KB

Versions: 78

Compression:

Stored size: 1.97 KB

Contents

require 'puppet/external/nagios'
require 'puppet/external/nagios/base'
require 'puppet/provider/naginator'

module Puppet::Util::NagiosMaker
  # Create a new nagios type, using all of the parameters
  # from the parser.
  def self.create_nagios_type(name)
    name = name.to_sym
    full_name = ("nagios_#{name}").to_sym

    raise(Puppet::DevError, "No nagios type for #{name}") unless nagtype = Nagios::Base.type(name)

    type = Puppet::Type.newtype(full_name) {}

    type.ensurable

    type.newparam(nagtype.namevar, :namevar => true) do
      desc "The name of this nagios_#{nagtype.name} resource."
    end

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

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

      defaultto do
        resource.class.defaultprovider.default_target
      end
    end

    target = "/etc/nagios/#{full_name.to_s}.cfg"
    provider = type.provide(:naginator, :parent => Puppet::Provider::Naginator, :default_target => target) {}
    provider.nagios_type

    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 `#{target}`, but
      you can send them to a different file by setting their `target` attribute.

      You can purge Nagios resources using the `resources` type, but *only*
      in the default file locations.  This is an architectural limitation.

    "
  end
end

Version data entries

78 entries across 78 versions & 4 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/util/nagios_maker.rb
puppet-parse-0.1.3 lib/vendor/puppet/util/nagios_maker.rb
puppet-parse-0.1.2 lib/vendor/puppet/util/nagios_maker.rb
puppet-parse-0.1.1 lib/vendor/puppet/util/nagios_maker.rb
puppet-2.7.26 lib/puppet/util/nagios_maker.rb
puppet-3.4.3 lib/puppet/util/nagios_maker.rb
puppet-2.7.25 lib/puppet/util/nagios_maker.rb
puppet-3.4.2 lib/puppet/util/nagios_maker.rb
puppet-2.7.24 lib/puppet/util/nagios_maker.rb
puppet-3.4.1 lib/puppet/util/nagios_maker.rb
puppet-3.4.0 lib/puppet/util/nagios_maker.rb
puppet-3.4.0.rc2 lib/puppet/util/nagios_maker.rb
puppet-3.4.0.rc1 lib/puppet/util/nagios_maker.rb
puppet-3.3.2 lib/puppet/util/nagios_maker.rb
puppet-3.3.1 lib/puppet/util/nagios_maker.rb
puppet-3.3.1.rc3 lib/puppet/util/nagios_maker.rb
puppet-3.3.1.rc2 lib/puppet/util/nagios_maker.rb
puppet-3.3.1.rc1 lib/puppet/util/nagios_maker.rb
puppet-3.3.0 lib/puppet/util/nagios_maker.rb
puppet-3.3.0.rc3 lib/puppet/util/nagios_maker.rb