blob: b1af057dc9abb8f2e5ced67377b7709eddd7c2c4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
require 'puppet'
require 'yaml'
unless Puppet.version >= '2.6.5'
fail "This report processor requires Puppet version 2.6.5 or later"
end
Puppet::Reports.register_report(:socket) do
configfile = File.join([File.dirname(Puppet.settings[:config]), "socket.yaml"])
# do not raise a error since this will show in puppet log
# raise(Puppet::ParseError, "Socket report config file #{configfile} not readable") unless
if File.exist?(configfile)
# TODO add support for using another user ?
config = YAML.load_file(configfile)
SOCKET_PATH = config[:socket_path]
else
SOCKET_PATH = nil
end
desc <<-DESC
Send notification of failed reports to a socket.
DESC
def process
if self.status == 'failed'
message = "Puppet run for #{self.host} #{self.status} at #{Time.now.asctime}."
if File.exist?(SOCKET_PATH)
Puppet::Util.execute("echo #{message} > #{SOCKET_PATH}" , "nobody", "nogroup")
end
end
end
end
|