[chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: run_context.include_recipe in a recipe within a role


Chronological Thread 
  • From: Jesse Nelson < >
  • To: " " < >
  • Subject: [chef] Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: run_context.include_recipe in a recipe within a role
  • Date: Wed, 29 May 2013 18:29:08 -0700

What about the case where you include_recipe from your provider in a rescue  gem require. so get the gem installed and continue on. 

I think this case is ok.  If the wrapper wants to change the behavior they can, and as an author I can set an attribute to disable the include or return from the included recipe. Possibly Install some other gem that satisfies the dep.

The reason for wanting to do this is hide the implementation. 

LWRPs should just work for the common case IMO. 

An alternative that i have used is an explicit  cookbook::library recipe that handles the setup for just the lib/LWRP. Usage. I like this as an operator because I can see this on the run_list and know the intent. 




On May 29, 2013, at 3:43 PM, Daniel DeLeo < "> > wrote:


On Wednesday, May 29, 2013 at 12:07 PM, John E. Vincent (lusis) wrote:

I'm still confused by this. The windows and runit resources, as an example, are not available to a recipe unless include_recipe is used at the top. They've always failed for me otherwise (regardless of including the dependency in metadata.rb). I never bothered to revisit if this was a bug and I've always done include_recipe "runit" (or any recipe for that matter) where I needed the resources from that LWRP in the recipe itself.

I'm totally willing to admit I've been wrong all this time but there was a reason I did it at one point and it fixed the problem at the time. I just never went back and challenged that assumption.
LWRPs, resource definitions, etc. are loaded from all available cookbooks (modulo a caveat that chef-solo now requires metadata deps to consider a cookbook "available"). Relevant Chef 11 code: https://github.com/opscode/chef/blob/master/lib/chef/run_context/cookbook_compiler.rb#L57-75

If you're talking about a LWRP or resource definition actually being able to succeed, then you will definitely need whatever system state it depends on to be available. Using runit as an example, you could probably write a "install-runit-my-own-way" cookbook to get runit on the system and then use the runit resource (resource definition until recently) without issue, but it definitely won't work if you haven't installed runit.

Bringing this back to the OP's issue, I think including a recipe (the normal way) to install prerequisites of a LWRP is the right way to go about it. If you are doing wizardry with chef internals, either 1) you're making something more complicated than it should be, 2) chef is making something more complicated than it should be, or 3) you're a wizard. So far, I'm inclined to think that including recipes from a provider falls into category #1, since you can just as easily and elegantly solve the problem with a role (or role cookbook if that's your thing). Am I missing something?


-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§