I have a simple attributes file: attributes/default.rb
.
default['simpleattr'] = 'file value'
And inside kitchen.yml
, I do
suites:
- name: default
run_list:
- recipe[simple::default]
attributes:
simpleattr: 'value from kitchen'
simple:
simpleattr: 'value from kitchen'
Inside the recipe, I do :
log "default['simpleattr']: "+node.default['simpleattr']
And I always get 'file value'
rather than 'value from kitchen'
as output.
I want to override the value in tests.
Don't access node values through node.default[]
, but use node[]
instead. Chef's attribute hierarchy automatically calculates the values according to its precedence levels.
I've reproduced your issue and uploaded it here on Github. The solution is as also previously described in my comment. Don't use
node.default['simpleattr']
but instead
node['simpleattr']
Then everything is as you expect and the output is
Recipe: simple::default
* log[default['simpleattr']: value from kitchen] action write