I read in Chef site that for default attributes specified in environment takes higher precedence than default attributes specified in roles. This makes sense as we may have different web-server for development, testing and production.
But in case of override attribute this is reverse i.e override attributes of roles takes precedence over override attribute of roles. I am not able to guess reason behind this ? Can anyone please explain me why chef chose such precedence ordering.
I am also adding complete list of attribute precedence as given in chef site
- The
defaultattribute specified in a cookbook attribute file. - The
defaultattribute specified in a recipe. - The
defaultattribute specified in an environment. - The
defaultattribute specified in a role. - The
force_defaultattribute specified in aa cookbook attribute file. - The
force_defaultattribute specified in a recipe. - The
normalattribute specified in a cookbook attribute file. - The
normalattribute specified in a recipe. - The
override attributespecified in a cookbook attribute file. - The
override attributespecified in a recipe. - The
override attributespecified in a role. - The
override attributespecified in an environment. - The
force_overrideattribute specified in a cookbook attribute file. - The
force_overrideattribute specified in a recipe. - The
automaticattribute collected during the Ohai run.
Thanks
defaultattributes set on a role take higher precedence over the ones set on the environment -- i.e. if you set the same default on both the role and the environment, the one on the role wins. The opposite is true foroverrideattributes. If you override an attribute on the environment, it will win over the overrides set elsewhere, including on roles. - cassianoleal