Embedded Node Attributes Not Being Read

I’m running ChefDK 0.12.0 with test kitchen 1.6.0 and chef-client 12.5.1. I have Chef attributes set in a custom cookbook (cookbook-A) by a custom wrapper cookbook (cookbook-wrapper), and then cookbook-wrapper calls a cookbook-A recipe with those Chef attributes but the Chef attributes are not being read properly.

In cookbook-A/attributes/do_something.rb:

default['cookbook-A']['my-attribute'] = ''
default['cookbook-A']['attribute-for-recipe'] = "Some text including #{node['cookbook-A']['my-attribute']}."

In cookbook-A/recipes/do_something.rb:

file '/path/to/file' do
  content node['cookbook-A']['attribute-for-recipe']
end

In cookbook-wrapper/attributes/default:

force_default['cookbook-A']['my-attribute'] = 'reset text'

In cookbook-wrapper/recipes/default:

include_recipe 'cookbook-A::do_something'

And yet the file’s contents is "Some text including " when it should be "Some text including reset text".

See https://coderanger.net/derived-attributes/ for an explanation and solution.

–Noah

Thanks, @coderanger! That did the trick. For all those following along at home, I replaced

# cookbook-A/attributes/do_something.rb:

default['cookbook-A']['attribute-for-recipe'] = "Some text including #{node['cookbook-A']['my-attribute']}."

with

# cookbook-A/attributes/do_something.rb:

default['cookbook-A']['attribute-for-recipe'] = "Some text including %{my-attribute}."

and replaced

# cookbook-A/recipes/do_something.rb

file '/path/to/file' do
  content node['cookbook-A']['attribute-for-recipe']
end

with

# cookbook-A/recipes/do_something.rb

file '/path/to/file' do
  content node['cookbook-A']['attribute-for-recipe'] % {my-attribute: node['cookbook-A']['my-attribute']}
end