[chef] Re: Re: Using gem_package in recipes causing strange behavior


Chronological Thread 
  • From: Cassiano Leal < >
  • To:
  • Subject: [chef] Re: Re: Using gem_package in recipes causing strange behavior
  • Date: Wed, 17 Apr 2013 08:54:27 -0300

I'm not entirely sure about your problem there, but it seems like your recipes are only able to run in a certain order.

If that's the case, recipe dependencies should probably best be explicitly declared. Example:

If recipe a::default depends on b::server, on a/recipes/default.rb you include b::server:

include_recipe "b::server"
<rest of a::default code>

This way, you ensure that b::server is executed prior to a::default. Do that for all recipes that have dependencies and your problem will go away. If you have too much of that, though, you'd probably best analyse your cookbooks for excessive coupling.

If nothing that I said relates to your problem, then an example repo is probably in order. :)

Cheers,
- cassiano

On Wednesday, April 17, 2013 at 04:48, Nabil Shuhaiber wrote:

Hi,

Yes I do understand that. Sorry I was not clear enough. I basically need access to the gem in my recipe. It seems like the chef runtime seems to skip all recipes in the run list until it gets to the first recipe containing the chef_gem statement and then continues from there. This causes it to fail as it has skipped most of the chef process. 

I just need the gems to install when it gets to the chef_gem line after sequentially running through all my recipes in order. 

If this still isn't clear I can spend some time putting together a small repro. 

Thanks

On Wednesday, April 17, 2013, Cassiano Leal wrote:
chef_gem installs the gem in Chef's Ruby, not on the system's.

If I understand you correctly, you want this gem to be available to Chef so that it can be used in your recipe, right?

If that's the case, then that's the right approach: use chef_gem so that it gets installed at compile time in Chef's Ruby so that it can be used later in the recipe.

If the gem is not installed at compile time and then you require it in the recipe, The chef client will throw an exception because it won't find the required class.

-- 
Cassiano Leal

On Tuesday, April 16, 2013 at 19:18, wrote:


I am using a number of gems in my recipes with gem_package such as below:

gem_package 'faraday' do
source "cookbooks/rabbitmq/files/default/faraday-0.8.7.gem"
action :install
end

These gem_package statements are located mid recipe and then I have a "require
'faraday'" straight after, so I can start using the gems in the recipe.

This specific recipe is 3rd out of 4 in the run list. When I run it seems to
skip everything until it gets to the gem_package statements . Why is this
happening? I have tried various different methods such as calling
g.run_action(:install) with no luck.

I was originally using chef_gem and read that it causes gems to be installed at
compile time but gem_package also seems to be doing that too.

Behaviour I am looking for is to install the gem at the point in the recipe
where it is being used.

I am new to chef (in windows) and this has got me stumped so appreciate any
help.



--
Best Regards,
Nabil Shuhaiber





Archive powered by MHonArc 2.6.16.

§