Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chef Node Attributes. Which ones are avaialble?

Tags:

chef-infra

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...)?
like image 545
iDev247 Avatar asked Mar 14 '13 02:03

iDev247


People also ask

What is node attribute in Chef?

An attribute is a specific detail about a node. Attributes are used by the chef-client to understand: The current state of the node. What the state of the node was at the end of the previous chef-client run.

What are node attributes?

Node attributes are a special type of option (name-value pair) that applies to a node object. Beyond the basic definition of a node, the administrator can describe the node's attributes, such as how much RAM, disk, what OS or kernel version it has, perhaps even its physical location.

Which of the following can be a node in Chef?

A node is any machine—physical, virtual, cloud, network device, etc. —that is under management by Chef.

What is node default Chef?

In short "node[a]" is used to read the existing value saved within the Chef node object and "node. default[a]" is used to set the value.


1 Answers

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.

like image 174
Holger Just Avatar answered Sep 28 '22 06:09

Holger Just