Search code examples
chef-infra

Chef Node Attributes. Which ones are avaialble?


I just started using Chef and I've noticed in some recipes there's stuff like node['cpu']['total'].

I searched in questions and online for stuff like "chef node attributes" but I can't find a list of available node attributes.

What I'm looking for is:

  1. Are all node[...] defined automatically?
  2. Where can I find a list of all available node attributes (cpu...)?

Solution

  • Are all node[...] defined automatically?

    No. some of them are set by Ohai at the start of a chef run. Some of them are set by (default) attributes of cookbooks and some of them are overwritten at various places in the system (e.g. roles, other recipes, ...)

    Where can I find a list of all available node attributes (cpu...)?

    That depends on the system you are running at, which ohai plugins you have installed and which cookbooks you have in your runlist. To get the full list of basic Ohai attributes, you can simply execute ohai on your shell which will output all automatic attributes. For the others, you have to look at your cookbooks.

    For documentation reference have a look at the Chef documentation. I linked a good starting point, but really understanding attributes is a bit complex as it is a rather flexible (and thus complex) system. You should browse a bit of the documentation.