For example, say I have a cookbook called "example". In its
attributes/default.rb file, it has these two lines:
default['example']['version'] = '1.0'
default['example']['module'] = "example-#{example['version']}"
By default, the value of node['example']['module'] should be properly set to
"example-1.0". If I set the version to "1.1" using a role, I can access
node['example']['module'] in a recipe, and its value should be "example-1.1",
which is great. However, if I set up a wrapper cookbook named
"mycompany-example" and have its attributes/default.rb file contain the line
"override['example']['version'] = '1.1'", accessing node['example']['module']
in a recipe will give me a value of "example-1.0", even though accessing
node['example']['version'] would correctly be '1.1'. The ideal outcome would
be to have the module value be "example-1.1", and I'm lost as to how to make
that happen.
You are running into this:TL;DRIn your wrapper cookbook either repeat the computed node attribute...```node.set['example']['version'] = '1.1'# not DRY but worksnode.set['example']['module'] = "example-#{example['version']}"```...or use this to re-evaluate the original attributes file in your wrapper cookbook (see http://docs.opscode.com/chef/essentials_cookbook_recipes.html#reload-attributes):```node.set['example']['version'] = '1.1'# now re-evaluate the default attributes file from the example cookbooknode.from_file(run_context.resolve_attribute("example", "default.rb"))
```Also notice that `set` is enough -- you don't need to `override`. Not sure if that was intended in your example...Cheers,Torben
Archive powered by MHonArc 2.6.16.