Learning the attribute precedence hierarchy
With roles, environments, cookbooks, recipes, and so on, there are many places that attributes can be defined. In addition, there are many types of attributes that can be used. If, as a slight exaggeration, the same attribute is defined in all possible resources, each with a different value, how do you know which value would be applied when chef-client converges the node? Consider a more real-world example if you use an application cookbook that has a default attribute defined for the install directory, and you need that app to install into a different directory, what type of attribute can you use, and where should you set it so that your value would be used instead of the default? The answer to these questions is found in the precedence hierarchy. The factors that determine precedence include the type of attribute, the source of the attribute, and of course, the order evaluated. Let's take a closer look at these factors now.