ruby 厨师中级班的处理程序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 厨师中级班的处理程序相关的知识,希望对你有一定的参考价值。

require 'rubygems'
require 'pony'

module MyCompany
  class EmailMe < Chef::Handler
  	def initialize(from_address, to_address)
      @from_address = from_address
      @to_address = to_address
    end

        def report
      status = success? ? "Successful" : "Failed"
      subject = "#{status} Chef run report from #{node.name}"
      report_string = ""

            # report on changed resources
      if ! run_status.updated_resources.empty?
        # get some info about all the changed resources!
        run_status.updated_resources.each do |r|
          report_string += "The resource #{r.name} was changed in cookbook #{r.cookbook_name} at #{r.source_line}\n"
        end
      else
        report_string += "No resources changed by chef-client\n"
      end

            Pony.mail(:to => @to_address,
                :from => @from_address,
                :subject => subject,
                :body => report_string)
    end
  end
end

以上是关于ruby 厨师中级班的处理程序的主要内容,如果未能解决你的问题,请参考以下文章

ruby 厨师中级班的Ohai模块重构

ruby 一个ruby脚本,用于创建一大堆厨师节点。

如何使用 Ruby 块在厨师食谱中分配变量

厨师库或定义?

ruby 中级烹饪书/ apache / recipes / default.rb

如何将linux命令输出到厨师属性