X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/7b9ec4b60ee39614d1d083d7220e76b07d2b275f..5bac522a83a65e8a6c0b20e179ee794321ad4a99:/cookbooks/chef/templates/default/report.rb.erb?ds=inline diff --git a/cookbooks/chef/templates/default/report.rb.erb b/cookbooks/chef/templates/default/report.rb.erb index 5e7886029..6b8ec5b9c 100644 --- a/cookbooks/chef/templates/default/report.rb.erb +++ b/cookbooks/chef/templates/default/report.rb.erb @@ -1,34 +1,35 @@ # DO NOT EDIT - This file is being maintained by Chef require "rubygems" -require "pony" - + class Chef class Handler class Email < Chef::Handler attr_reader :config - def initialize(config={}) + def initialize(config = {}) @config = config @config[:from] ||= "root@openstreetmap.org" @config end - + def report - if failed? and not exception.is_a? SystemExit + if failed? && !exception.is_a?(SystemExit) subject = "Chef run failed on #{node.name}" message = "#{run_status.formatted_exception}\n" - elsif elapsed_time > 300 + elsif elapsed_time > 600 subject = "Chef run took #{elapsed_time} on #{node.name}" message = "" end - - if subject - message << Array(backtrace).join("\n") - Pony.mail(:to => @config[:to], :from => @config[:from], - :subject => subject, :body => message, :via => :smtp) - end + return unless subject + + message << Array(backtrace).join("\n") + + require "pony" + + Pony.mail(:to => @config[:to], :from => @config[:from], + :subject => subject, :body => message, :via => :smtp) end end end