Wednesday, September 13, 2017

chef-The Node Object

What is the Node Object?

Node vs Node Object

A node is defined as any physical or virtual machine that is configured
to be maintained by Chef.
At the Gap, a virtual machine can be Vmware, Openstack, Vagrant or even
Docker
If it runs chef-client, it is a Node.

The Node Object is the representation of that Node inside of Chef
The node object can be described as a collection of attributes
The node object can be represented in Ruby, JSON or YMAL

Nodes in Chef

Every Node must have a unique name within an Organization
§ Chef defaults to the Fully Qualified Domain Name of the machine.
§ For the purposes of this class, we have overridden the default
behavior and given the node a short name (node1) to make the typing
easier. (You’re welcome)

At Gap, node name should follow the naming convention

List all nodes in the Organization using
knife

knife node list


List all clients in the Organization using
knife

knife client list


List all Attributes on our Node

knife node show node1 -l


Run Ohai on your Node

sudo ohai | less



{
"kernel": {
"name": "Linux",
"release": "2.6.32-504.1.3.el6.x86_64",
"version": "#1 SMP Tue Nov 11 17:57:25 UTC 2014",
"machine": "x86_64",
"os": "GNU/Linux",
"modules": {
"nls_utf8": {
"size": "1455",
"refcount": "0”
},
"ipt_REJECT”:


Can I see the node data in JSON? YAML?

kknife node show node1 -Fj


{
"name": "node1",
"chef_environment": "_default",
"run_list": [
"recipe[mysite]”
],
"normal": {
"tags": [
]
}
}


Show only the Fully Qualified Domain Name

knife node show node1 -a fqdn

node1:
fqdn: node1.novalocal


Show only the Fully Qualified Domain Name

knife search node '*:*' -a fqdn

1 items found
node1:
fqdn: node1.novalocal















No comments:

Post a Comment