[chef] Re: When is it necessary to use include_attribute?


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: When is it necessary to use include_attribute?
  • Date: Thu, 27 Mar 2014 10:09:00 -0700



On Thursday, March 27, 2014 at 10:01 AM, Christopher Armstrong wrote:

> Ohai Chefs,
>  
> Say I have a cookbook bar. This cookbook depends on a cookbook foo. I have 
> included foo as a dependency in my metadata.rb and I'm doing an 
> include_recipe "foo" in bar's default recipe. Groovy.
>  
> I need to override a few of foo's default attributes in bar. So, in bar's 
> attributes.rb, I override these attributes.
>  
> Now my question: ordinarily, I would include_attributes "foo" in bar before 
> I override these attributes, as alphabetically foo comes after bar, and I 
> want to ensure that those attributes are parsed before I override them.  
>  
> That's how I've been doing things. Today, though, I'm wondering if that's 
> even necessary, because I have listed foo as a dependency in bar's 
> metadata. Does Chef's dependency resolver parse default attributes for all 
> dependencies before getting to a cookbook's own attributes?  
>  
> Hope that makes sense!
>  
> Thanks,
>  
> Chris  
In Chef 10 it was a total mess, so we’ll skip that. But if you are still 
using 10.x then include attribute is definitely needed to have any semblance 
of sanity.

In Chef 11, cookbooks get ordered based on dependencies, and then within a 
cookbook, default.rb gets loaded first and then it’s lexical (alphabetical, 
more or less) sort order after that.

If you run with -ldebug, you should see log messages for your 
include_attributes statements that say whether they’re no-ops or not.


--  
Daniel DeLeo






Archive powered by MHonArc 2.6.16.

§