1
votes

I am creating a wrapper cookbook for the Apache cookbook to handle changes needed to support Chef, Cobbler, and a few other cookbooks.

I would like to avoid having the Chef recipe attributes overwrite the Cobbler recipe attributes and such (avoid name space conflicts).

Creating separate recipes and templates is easy; just create different file names. How do you keep attributes separate and prevent name space conflicts? It is possible to create different attributes files, but can Chef be told to only use one attribute file per recipe (recipes/chef.rb -> attributes/chef.rb)?

1
check this dicussionDmitry Savinkov
"Chef recipe attributes" There's nothing like this. You can set attributes within recipes (but I discourage it as it's hard to follow later) your question is highly unclear on what you wish to avoid. For the rest @MarkOConnor's answer is the way to go to understand the concept of wrapper cookbooks.Tensibai

1 Answers

1
votes

Namespacing the attribute using the cookbook name is merely a convention, in Chef attributes are designed to be overridden by other mechanisms, like wrapper cookbooks, roles or environments.

Chef has rules about how node attributes are set and in the documentation it's call "precedence":

https://docs.chef.io/attributes.html#attribute-precedence

In brief cookbooks normally set a "default" value which the lowest level and allows other cookbooks to override using a "normal" value. For example of how this works I have include two wrapper cookbooks

Hope this helps. Attribute precedence is an important but subtle chef concept.