[chef] Re: Re: Re: Re: Re: accessing environment attributes in cookbooks


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Re: accessing environment attributes in cookbooks
  • Date: Wed, 26 Dec 2012 11:30:08 -0800


On Wednesday, December 26, 2012 at 11:16 AM, Steven Lehrburger wrote:

Then if I put this in my attributes/default.rb file:

default['my_cookbook']['cookbook_dir'] = "#{node[: my_attr]}/some/directory"

That's what I was getting at with my explanation earlier. In Chef 10.x (down to 0.8.x), the attribute precedence described here:

http://docs.opscode.com/essentials_cookbook_attribute_files_attribute_precedence.html

is implemented by the order in which the various attribute sources are merged in. Since attribute files are lower precedence than roles and environments, they are not merged in until later so they're invisible to attributes files. Your best bet is to move code that computes attributes based on other attributes into your recipes for now.

As mentioned before, Chef 11 fixes this so the code snippet you posted would work as expected.
Which is what I want. I would guess I'm just not using the proper syntax to define my attribute? But I've tried it with everything I can think of, and it's fine if I have to explicitly load the environment until Chef 11 :)

Thanks!

/~s


-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§