I know this is more a ruby
question than chef
, but...
I have some attributes like:
default['my_cookbook']['some_namespace1']['some_attribute1'] = 'some_value1'
default['my_cookbook']['some_namespace1']['some_attribute2'] = 'some_value2'
default['my_cookbook']['some_namespace1']['some_attribute2'] = 'some_value3'
...
default['my_cookbook']['some_namespace2']['some_attribute1'] = 'some_value1'
default['my_cookbook']['some_namespace2']['some_attribute2'] = 'some_value2'
default['my_cookbook']['some_namespace2']['some_attribute2'] = 'some_value3'
...
On the other hand, I am creating a template resource like this:
template 'template_name' do
source 'template_source.erb'
variables (
my_namespace_1: node['my_cookbook']['some_namespace1'],
my_namespace_2: node['my_cookbook']['some_namespace2']
)
end
Then in the template_source.erb
I try:
...
<%= @my_namespace_1['some_attribute1'] %> #=> 'some_value1'
...
However when I run Kitchen I get this, instead of 'some_value1'
:
Chef::Mixin::Template::TemplateError
------------------------------------
undefined method `[]' for nil:NilClass
How should I send the template variable to use it this way?