summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-02-12 16:00:29 -0600
committerJames Turnbull <james@lovedthanlost.net>2009-02-13 14:16:36 +1100
commit70ea39af65f7e56ce151c9f9ca444261d0332454 (patch)
treebeb3715a53e61174b12097482bd27024670a1b7e /lib/puppet
parent4dfa034dc8a569634d8b5672f66158157ddddb28 (diff)
downloadpuppet-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/puppet')
-rw-r--r--lib/puppet/provider/naginator.rb5
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)