]> git.openstreetmap.org Git - chef.git/blob - cookbooks/chef/templates/default/report.rb.erb
move nominatim traffic to dulcy
[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         if failed? && !exception.is_a?(SystemExit)
18           subject = "Chef run failed on #{node.name}"
19           message = "#{run_status.formatted_exception}\n"
20         elsif elapsed_time > 300
21           subject = "Chef run took #{elapsed_time} on #{node.name}"
22           message = ""
23         end
24
25         return unless subject
26
27         message << Array(backtrace).join("\n")
28
29         require "pony"
30
31         Pony.mail(:to => @config[:to], :from => @config[:from],
32                   :subject => subject, :body => message, :via => :smtp)
33       end
34     end
35   end
36 end