]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/chef/templates/default/report.rb.erb
Try and ensure tile server use an integer number of listen buckets
[chef.git] / cookbooks / chef / templates / default / report.rb.erb
index 5e788602979eb8cde086f3b469eb2f5ec6c38977..4265d0660cb18412a5070ee8ee44152cb024210f 100644 (file)
@@ -1,33 +1,45 @@
 # 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
-          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 = ""
+        from_address = @config[:from]
+        to_address = @config[:to]
+
+        if failed? && !exception.is_a?(SystemExit)
+          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 message_subject
+
+        message_body << Array(backtrace).join("\n")
+
+        require "mail"
+
+        Mail.defaults do
+          delivery_method :exim, :location => "/usr/sbin/exim"
         end
-        
-        if subject
-          message << Array(backtrace).join("\n")
 
-          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