- From: <
>
- To:
- Subject: [chef] Re: Re: Library function in recipe
- Date: Wed, 8 Aug 2012 13:11:55 -0700 (PDT)
I am getting a method not defined exception with the following code in the
recipe. I tried both the commented and un-commented lines in the ruby_block
below and both did not work.
The library is listed below as well.
<code>
class Chef::Recipe
include EventLogLib
end
ruby_block "mystart" do
block do
#EventLogLib.logEvent("def","START")
logEvent("def","START")
end
end
</code>
Here is the library defined in the cookbook.
<code>
module EventLogLib
def logEvent(msg, msgstatus)
require "rubygems"
require "stomp"
stomp_server = node[:chef_handler][:stomp_server]
stomp_port = node[:chef_handler][:stomp_port]
stomp_queue = node[:chef_handler][:stomp_queue]
stomp_user = node[:chef_handler][:stomp_user]
stomp_password = node[:chef_handler][:stomp_password]
eventQueue = "#{stomp_queue}"
summary = { :deploymentId => node.deployment_id,
:vmId => node.vm_id,
:vmHostname => node.hostname,
:vmIpaddress => node.ipaddress,
:stepMessage => msg,
:stepStatus => msgstatus
}
client = Stomp::Client.new(stomp_user, stomp_password, stomp_server,
stomp_port, true)
client.publish(eventQueue, summary.to_json, {:persistent => false})
client.close
Chef::Log.info ("message #{summary.to_json} sent to queue
#{eventQueue}")
end
end
</code>
- [chef] Re: Re: Library function in recipe, vin4gud, 08/08/2012
Archive powered by MHonArc 2.6.16.