- From: Andrea Campi <
>
- To:
- Subject: [chef] Re: How can we send parametrs to handler?
- Date: Fri, 13 Apr 2012 11:07:35 +0200
On Fri, Apr 13, 2012 at 11:03 AM, Ilya Maltsev
<
>
wrote:
>
Hello!
>
>
We are writing handler(message.rb).
>
>
>
>
require "rubygems"
>
require "amqp"
>
>
require "chef"
>
>
.....
>
>
class Test < Chef::Handler
>
>
def initialize(ipad)
>
@ipad = ipad
>
end
>
>
puts @ipad
>
>
>
...........
>
end
>
>
>
We have recipe where we call this handler:
>
>
>
.....
>
include_recipe "chef_handler"
>
chef_handler "Chef::Handler::Test" do
>
arguments ['something']
>
source "/var/chef/handlers/message.rb"
>
action :enable
>
end
>
.........
>
>
>
We can't send parameters from recipe to handler, the result of running
>
recipe is: @ipad = nil
>
How can we send parametrs to handler?
Is "puts @ipad" really at class scope, outside any method?
That's not what you want.
Try:
class Test < Chef::Handler
def initialize(ipad)
@ipad = ipad
end
def report
puts @ipad
end
end
Archive powered by MHonArc 2.6.16.