X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/ceb801ff008b6125d3a359635295f5091088f520..c63cdfe9e4a737154c75ffa47e0d90ae057065cd:/cookbooks/chef/templates/default/report.rb.erb diff --git a/cookbooks/chef/templates/default/report.rb.erb b/cookbooks/chef/templates/default/report.rb.erb index 0317f9286..20e32ef4f 100644 --- a/cookbooks/chef/templates/default/report.rb.erb +++ b/cookbooks/chef/templates/default/report.rb.erb @@ -14,22 +14,29 @@ class Chef end def report + from_address = @config[:from] + to_address = @config[:to] + if failed? && !exception.is_a?(SystemExit) - subject = "Chef run failed on #{node.name}" - message = "#{run_status.formatted_exception}\n" - elsif elapsed_time > 300 - subject = "Chef run took #{elapsed_time} on #{node.name}" - message = "" + message_subject = "Chef run failed on #{node.name}" + message_body = "#{run_status.formatted_exception}\n" + elsif elapsed_time > 600 + message_subject = "Chef run took #{elapsed_time} on #{node.name}" + message_body = "" end - return unless subject + return unless message_subject - message << Array(backtrace).join("\n") + message_body << Array(backtrace).join("\n") - require "pony" + require "mail" - Pony.mail(:to => @config[:to], :from => @config[:from], - :subject => subject, :body => message, :via => :smtp) + Mail.deliver do + to to_address + from from_address + subject message_subject + body message_body + end end end end