I've noticed that attributes in environments do not get applied if I use node.default
in cookbooks (instead the cookbook attributes get applied). But, the attributes changed in environments get applied if I use node
instead; why? I thought node
and node.default
are one and the same?
Node attribute precedence can be confusing. The document does help, once you read it a couple of times
https://docs.chef.io/attributes.html
My advice is as follows:
- Set default attributes in an attributes file within your cookbook. Don't confuse yourself by doing this within recipes as well.
- Override the attributes of other cookbooks by setting "normal" attributes and again do this in an attributes file within your cookbook
- At runtime using Environment or Role attributes to override all attributes set within cookbooks.
- Never edit the node attributes directly on the chef server. There is no transactional locking, which means your update could be lost if a chef client is running at the same time....
The objective here is consistency