From 0cfc89fa15dee7dfd2d5a0a096ebae44e8973d5f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 17 Nov 2017 16:00:02 +0000 Subject: [PATCH 1/1] Fix issues with chef report handler --- .../chef/templates/default/report.rb.erb | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/cookbooks/chef/templates/default/report.rb.erb b/cookbooks/chef/templates/default/report.rb.erb index 518ec1383..20e32ef4f 100644 --- a/cookbooks/chef/templates/default/report.rb.erb +++ b/cookbooks/chef/templates/default/report.rb.erb @@ -14,25 +14,28 @@ 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" + message_subject = "Chef run failed on #{node.name}" + message_body = "#{run_status.formatted_exception}\n" elsif elapsed_time > 600 - subject = "Chef run took #{elapsed_time} on #{node.name}" - message = "" + 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 "mail" Mail.deliver do - to @config[:to] - from @config[:from] - subject subject - body message + to to_address + from from_address + subject message_subject + body message_body end end end -- 2.43.2