aboutsummaryrefslogtreecommitdiffstats
path: root/modules/report-socket
diff options
context:
space:
mode:
authorMichael Scherer <misc@mageia.org>2012-01-15 10:11:58 +0000
committerMichael Scherer <misc@mageia.org>2012-01-15 10:11:58 +0000
commitc5d67a3756da7d4cb611d07250c63201aa2d794a (patch)
tree98250e34c597a73e977cff7c24f3c1f9ea5da19d /modules/report-socket
parent0301384465a57f68061340287061ba9b26b90097 (diff)
downloadpuppet-c5d67a3756da7d4cb611d07250c63201aa2d794a.tar
puppet-c5d67a3756da7d4cb611d07250c63201aa2d794a.tar.gz
puppet-c5d67a3756da7d4cb611d07250c63201aa2d794a.tar.bz2
puppet-c5d67a3756da7d4cb611d07250c63201aa2d794a.tar.xz
puppet-c5d67a3756da7d4cb611d07250c63201aa2d794a.zip
also rename the module
Diffstat (limited to 'modules/report-socket')
-rw-r--r--modules/report-socket/lib/puppet/reports/socket.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/report-socket/lib/puppet/reports/socket.rb b/modules/report-socket/lib/puppet/reports/socket.rb
new file mode 100644
index 00000000..f682cb98
--- /dev/null
+++ b/modules/report-socket/lib/puppet/reports/socket.rb
@@ -0,0 +1,28 @@
+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"])
+ raise(Puppet::ParseError, "Socket report config file #{configfile} not readable") unless File.exist?(configfile)
+
+ config = YAML.load_file(configfile)
+ SOCKET_PATH = config[:socket_path]
+ # TODO add support for using another user ?
+
+ 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