Chef is a configuration
management technology developed by Opscode to manage infrastructure on physical
or virtual machines. It is an open-source developed using Ruby, which helps in
managing complex infrastructure on the fly.
Knife is Chef's command-line
tool to interact with the Chef server and help the user to manage
- Nodes
- Cookbooks and recipes
- Roles, Environments, and Data Bags
- Resources within various cloud
environments
- The installation of Chef Infra Client
onto nodes
- Searching of indexed data on the Chef
Infra Server
In this article, we will be learning some of the most useful Chef Knief Commands.
Purpose
|
Commands
|
To Create cookbook
|
knife cookbook create
apache
|
To upload cookbook to
chef-server
|
knife cookbook upload apache
|
To add recipe as runlist
to a node
|
knife node run_list
add NODENAME “recipe[NAME]
|
To get knife help
|
knife -h
|
To display the attributes
of the node
|
knife node show
NODENAME -a attributes (a-b-c-d)0
|
To search for Linux
node
|
knife search node
“os:linux”
|
To display the platform
for Linux node
|
knife search node
“os:linux” -a platform
|
To display all the environment
|
knife environment
list -w
|
To compare between
two environments
|
knife environment compare test1
knife environment compare test2 |
To delete environment
|
knife environment delete dev
|
To Display environment
information
|
knife environment show prod
|
To Create a new role
|
knife role create role_name
|
To list all role
|
knife role list -w
|
To Delete the role
|
knife role delete
role_name
|