diff options
author | Luke Kanies <luke@madstop.com> | 2009-02-12 16:00:29 -0600 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-02-13 14:16:36 +1100 |
commit | 70ea39af65f7e56ce151c9f9ca444261d0332454 (patch) | |
tree | beb3715a53e61174b12097482bd27024670a1b7e /lib | |
parent | 4dfa034dc8a569634d8b5672f66158157ddddb28 (diff) | |
download | puppet-70ea39af65f7e56ce151c9f9ca444261d0332454.tar.gz puppet-70ea39af65f7e56ce151c9f9ca444261d0332454.tar.xz puppet-70ea39af65f7e56ce151c9f9ca444261d0332454.zip |
Adding a post-processor for Nagios names.
This is a brutal hack until Puppet correctly supports
multiple primary keys. It basically just comments out
_naginator_name before writing to disk, and uncomments
it when reading. This allows Puppet to use it
while Nagios ignores it.
Yes, a stupid hack, but it appears to work.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/provider/naginator.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb index 233d82eb6..5510eb9c8 100644 --- a/lib/puppet/provider/naginator.rb +++ b/lib/puppet/provider/naginator.rb @@ -7,6 +7,7 @@ require 'puppet/external/nagios' # The base class for all Naginator providers. class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile + NAME_STRING = "## --PUPPET_NAME-- (called '_naginator_name' in the manifest)" # Retrieve the associated class from Nagios::Base. def self.nagios_type unless defined?(@nagios_type) and @nagios_type @@ -24,14 +25,14 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile def self.parse(text) begin - Nagios::Parser.new.parse(text) + Nagios::Parser.new.parse(text.gsub(NAME_STRING, "_naginator_name")) rescue => detail raise Puppet::Error, "Could not parse configuration for %s: %s" % [resource_type.name, detail] end end def self.to_file(records) - header + records.collect { |record| record.to_s }.join("\n") + header + records.collect { |record| record.to_s }.join("\n").gsub("_naginator_name", NAME_STRING) end def self.skip_record?(record) |