Chef role and default default attributes not available

Say I have the following role as a chef:

name "test" description "role for test" run_list %w(recipe[cookbook_name]) default_attributes( :cookbook_name => { :a => 1 } ) 

And the corresponding environment:

 name "test environment" description "environment for test" default_attributes( :cookbook_name => { :b => 2 } ) 

And then in my cookbook attributes I have something like:

 parent = default[:cookbook_name] parent[:c] = 3 

The documentation of the attributes would make me believe that they would be available in the context of the recipe from node[:cookbook_name][:a] or node[:cookbook_name][:b] . However, when I try to access the ones in my actual cookbook, I get nil . What's happening? I do not understand the role of these attributes? I think it's worth noting that even if I set the default values ​​for these attributes in the attribute file, I get the same result, making me believe that I am referring to the attributes incorrectly.

What am I doing wrong?

+4
source share
1 answer

This is really how things should work. Inside the cookbook_name recipe, you can access the hash :cookbook_name with two elements :a and :b .

Have you installed the startup list and environment in node to include the role and environment you specified? Running a knife node show should show this.

+2
source

All Articles