[chef] Re: Nested node attributes not working as expected when using overrides?


Chronological Thread 
  • From: Bryan Baugher < >
  • To:
  • Subject: [chef] Re: Nested node attributes not working as expected when using overrides?
  • Date: Fri, 19 Oct 2012 09:47:30 -0500

Yes I believe this is expected. I ran across this problem and the solution is that if you ever use nested attributes, you should always use them in your recipes and not in attributes as Chef cannot guarantee the ordering of when things are loaded (i.e. environments, attributes files, roles...)

On Fri, Oct 19, 2012 at 9:43 AM, Torben Knerr < " target="_blank"> > wrote:
Hi Chefs!

I'm often using something like this in my attributes/default.rb:

    default['my_recipe']['base_dir']  = '/path/to/basedir'
    default['my_recipe']['other_dir']  = "#{node['my_recipe']['base_dir']}/otherdir"

This looks sane at first, but as soon as I'm overriding the default value for ['my_recipe']['base_dir'], e.g.  in a role like so...

    ...
    default_attributes({
      :my_recipe => {
        :base_dir => '/somewhere/else'
      }
    })
    ...

...I get a weird behavior when using the node attributes in my recipe:

=> node['my_recipe']['base_dir'] renders to '/somewhere/else'
=> node['my_recipe']['other_dir'] renders to '/path/to/basedir/otherdir'

Is this the expected behaviour?!

Cheers,
Torben

P.S.: this was under omnibus chef 10.14.4 on a 64 bit Ubuntu 12.04



--
-Bryan



Archive powered by MHonArc 2.6.16.

§