12
votes

When I create attributes in my cookbook's attributes /attributes/default.rb things work fine.

If I add a recipe to my cookbook, say /recipes/dofubar.rb, I expect that attributes defined in /attributes/dofubar.rb to be loaded. They do not appear to be.

Is there a way to define one set of default attributes for one recipe and other sets for other recipes?

1

1 Answers

21
votes

There is no correlation between attribute file names and recipes. All files in the attributes/ folder are loaded in order during the start of the Chef Client run. Even if you name an attribute.rb file the same as a recipe, Chef makes no correlation. All attribute files will be loaded each time.