]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/chef/templates/default/report.rb.erb
Use mail gem instead of pony
[chef.git] / cookbooks / chef / templates / default / report.rb.erb
index 5e788602979eb8cde086f3b469eb2f5ec6c38977..518ec13837734ef1d5ea998876479cda9b46e9e3 100644 (file)
@@ -1,33 +1,38 @@
 # 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
+        if failed? && !exception.is_a?(SystemExit)
           subject = "Chef run failed on #{node.name}"
           message = "#{run_status.formatted_exception}\n"
-        elsif elapsed_time > 300
+        elsif elapsed_time > 600
           subject = "Chef run took #{elapsed_time} on #{node.name}"
           message = ""
         end
-        
-        if subject
-          message << Array(backtrace).join("\n")
 
-          Pony.mail(:to => @config[:to], :from => @config[:from],
-                    :subject => subject, :body => message, :via => :smtp)
+        return unless subject
+
+        message << Array(backtrace).join("\n")
+
+        require "mail"
+
+        Mail.deliver do
+          to @config[:to]
+          from @config[:from]
+          subject subject
+          body message
         end
       end
     end