Run chef_recipe inside the chef resources

HI,

I need to run chef_recipe inside the chef resources like

ruby_block “XXXXXXX” do
block do
f $inc == 1 then
puts "call rollback method!"
include_recipe "rollback::stopservices"
else
puts "No need to call rollback method!"
end
end
end

but its shows error, I need to know it is possible to call chef recipe from any
chef resources in one recipe?
and how can I call one chef resources from another chef resource? same or diff
resources???

Thanks in advance

Regards,
ganesan.A

On Thu, Sep 18, 2014 at 05:50:53AM -0700, ganesan15785@gmail.com wrote:

I need to run chef_recipe inside the chef resources like

ruby_block "XXXXXXX" do
block do
if $inc == 1 then
puts "call rollback method!"
include_recipe "rollback::stopservices"
else
puts "No need to call rollback method!"
end
end

but its shows error, I need to know it is possible to call chef recipe from any
chef resources in one recipe?
and how can I call one chef resources from another chef resource? same or diff
resources???

Perhaps in your case you should notify some stops:

http://docs.getchef.com/chef/resources.html#notifications

I also extracted this code from the zookeeper_bridge cookbook with a
recipe_block implementation example:

It is very hackish. But maybe it can help you.

Hey Ganesan,

You dont need ruby block to do that until you are using it for notification
from other resource.

You can directly use if else block and call include recipe for eg.
runcontext.include_recipe "rollback::stopservices"
On Sep 18, 2014 6:21 PM, ganesan15785@gmail.com wrote:

HI,

I need to run chef_recipe inside the chef resources like

ruby_block "XXXXXXX" do
block do
f $inc == 1 then
puts "call rollback method!"
include_recipe "rollback::stopservices"
else
puts "No need to call rollback method!"
end
end
end

but its shows error, I need to know it is possible to call chef recipe
from any
chef resources in one recipe?
and how can I call one chef resources from another chef resource? same or
diff
resources???

Thanks in advance

Regards,
ganesan.A