[chef] 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: Daniel DeLeo < >
  • To:
  • Cc: " " < >
  • Subject: [chef] 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 15:43:07 -0700


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.

§