]> git.openstreetmap.org Git - chef.git/blob - cookbooks/chef/templates/default/report.rb.erb
Put web site back online
[chef.git] / cookbooks / chef / templates / default / report.rb.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 require "rubygems"
4
5 class Chef
6   class Handler
7     class Email < Chef::Handler
8       attr_reader :config
9
10       def initialize(config = {})
11         @config = config
12         @config[:from] ||= "root@openstreetmap.org"
13         @config
14       end
15
16       def report
17         from_address = @config[:from]
18         to_address = @config[:to]
19
20         if failed? && !exception.is_a?(SystemExit)
21           message_subject = "Chef run failed on #{node.name}"
22           message_body = "#{run_status.formatted_exception}\n"
23 #        elsif elapsed_time > 600
24 #          message_subject = "Chef run took #{elapsed_time} on #{node.name}"
25 #          message_body = ""
26         end
27
28         return unless message_subject
29
30         message_body << Array(backtrace).join("\n")
31
32         require "mail"
33
34         Mail.deliver do
35           to to_address
36           from from_address
37           subject message_subject
38           body message_body
39         end
40       end
41     end
42   end
43 end