While using any tool, 80% of all work is accomplished by very small percentage of commands available. Following are some of the commonly used Chef Knife commands.
To create a new cookbook
1
knife cookbook create cookbook_name
Note: use underscore instead of “-” (hyphen) in cookbook names. Hypen seem to prevent identification of LWRPs included in the cookbook.
To upload a new or modified cookbook
1
knife cookbook upload cookbook_name
To list all the nodes currently defined in Chef
1
knife node list
To show details about a node
1
knife node show node_name -l
Note: -l option generates a detailed list of properties about the node. Leaving it out will generate a summary about the node.
Use -a option to query about a particular node attribute
To edit a new node or modifying an existing node
1
knife node edit node_name
This will let you edit the node details using the default editor set
To add a node defined in a file to Chef
1
knife node from file file_name
To list all the roles defined in Chef
1
knife role list
To show details about a role
1
knife role show role_name
Use -a option to query about a particular role attribute value