Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

During a chef run how does node differ from node.default?

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?


1 Answers

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:

  1. Set default attributes in an attributes file within your cookbook. Don't confuse yourself by doing this within recipes as well.
  2. Override the attributes of other cookbooks by setting "normal" attributes and again do this in an attributes file within your cookbook
  3. At runtime using Environment or Role attributes to override all attributes set within cookbooks.
  4. 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

like image 61
Mark O'Connor Avatar answered Jan 03 '26 14:01

Mark O'Connor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!