Knife is a command-line tool that provides an interface between a local Chef repository and the Chef Server. Knife helps users of Chef to manage:
Note
The Knife Quick Reference provides an all-in-one quick reference of Knife commands. View a web-based PNG file here: http://docs.opscode.com/_images/qr_knife_web.png. Or download the source files from here: https://github.com/opscode/quick-reference. Print the front/back source files and laminate them for best effect.
| Topic | Description |
|---|---|
| Working with Knife | Knife runs from a management workstation and sits in-between a Chef server and an organization’s infrastructure. |
| Common Options | There are many options that are available for all Knife sub-commands. |
Knife includes the following sub-commands:
| Sub-command | Description |
|---|---|
| knife bootstrap | The bootstrap subcommand is used run a bootstrap operation that installs Chef on the target system. The bootstrap operation must specify the IP address or FQDN of the target system. |
| knife client | The client subcommand is used to manage an API client list and their associated RSA public key-pairs. This allows authentication requests to be made to the Chef Server by any entity that uses the Chef Server API, such as the chef-client and Knife. |
| knife configure | The configure subcommand is used to create the knife.rb and client.rb files so that they can be distributed to workstations and nodes. |
| knife cookbook | The cookbook subcommand is used to interact with cookbooks that are located on the Chef Server or the local Chef repository. |
| knife cookbook site | The cookbook site subcommand is used to interact with cookbooks that are located at https://cookbooks.opscode.com. A user account is required for any community actions that write data to this site. |
| knife data bag | The data bag subcommand is used to manage arbitrary stores of globally available JSON data. |
| knife delete | The delete subcommand is used to delete an object from a Chef Server. |
| knife diff | The diff subcommand is used to compare the differences between files and directories on the Chef Server and in the Chef repository. |
| knife download | The download subcommand is used to download roles, cookbooks, environments, nodes, and data bags from the Chef Server to the current working directory.. |
| knife environment | The environment subcommand is used to manage environments within a single organization on the Chef Server. |
| knife exec | The exec subcommand uses the Knife configuration file to execute Ruby scripts in the context of a fully configured chef-client. This subcommand is most often used to run scripts that will only access Chef Server one time (or otherwise very infrequently). Use this subcommand any time that an operation does not warrant full usage of the Knife subcommand library. |
| knife index rebuild | The index rebuild subcommand is used to rebuild the search indexes for the open source Chef Server. This operation is destructive and may take some time. |
| knife list | The list subcommand is used to view a list of objects on the Chef Server. |
| knife node | The node subcommand is used to manage the nodes that exist on a Chef Server. |
| knife raw | The raw subcommand is used to send a REST request to a specified path using the Chef Server API. |
| knife recipe list | The recipe list subcommand is used to view all of the recipes that are on a Chef Server. A regular expression can be used to limit the results to recipes that match a specific pattern. The regular expression must be within quotes and not be surrounded by forward slashes (/). |
| knife role | The role subcommand is used to manage the roles that are associated with one or more nodes on a Chef Server. |
| knife search | The search subcommand is used run a search query for information that is indexed on a Chef Server. |
| knife show | The show subcommand is used to view the details of one (or more) objects on the Chef Server. |
| knife ssh | The ssh subcommand is used to invoke SSH commands (in parallel) on a subset of nodes within an organization, based on the results of a search query. |
| knife status | The status subcommand is used to display a brief summary of the nodes on a Chef Server, including the time of the most recent successful chef-client run. |
| knife tag | The tag subcommand is used to apply tags to nodes on a Chef Server. |
| knife upload | The upload subcommand is used to upload roles, cookbooks, environments, and data bags to the Chef Server from the current working directory in the Chef repository. |
| knife user | The user subcommand is used to manage the list of Chef users and their associated RSA public key-pairs. |