1 |
require 'puppet' |
2 |
require 'yaml' |
3 |
|
4 |
unless Puppet.version >= '2.6.5' |
5 |
fail "This report processor requires Puppet version 2.6.5 or later" |
6 |
end |
7 |
|
8 |
Puppet::Reports.register_report(:irc_ii) do |
9 |
configfile = File.join([File.dirname(Puppet.settings[:config]), "irc_ii.yaml"]) |
10 |
raise(Puppet::ParseError, "XMPP report config file #{configfile} not readable") unless File.exist?(configfile) |
11 |
|
12 |
config = YAML.load_file(configfile) |
13 |
II_PATH = config[:ii_path] |
14 |
|
15 |
desc <<-DESC |
16 |
Send notification of failed reports to an IRC channel, using a existing ii setup. |
17 |
DESC |
18 |
|
19 |
def process |
20 |
if self.status == 'failed' |
21 |
message = "Puppet run for #{self.host} #{self.status} at #{Time.now.asctime}." |
22 |
if File.exist?(II_PATH) |
23 |
Puppet::Util::SUIDManager.run_and_capture("echo #{message} > #{II_PATH}" , "nobody", "nogroup") |
24 |
end |
25 |
end |
26 |
end |
27 |
end |