KNIFE(1) | knife | KNIFE(1) |
knife - The man page for the knife command line tool.
knife is a command-line tool that provides an interface between a local chef-repo and the Chef server. knife helps users to manage:
Knife subcommands:
knife runs from a management workstation and sits in-between a Chef server and an organization's infrastructure. knife interacts with a Chef server by using the same REST API that is used by a chef-client. Role-based authentication controls (RBAC) can be used to authorize changes when knife is run with Enterprise Chef. knife is configured during workstation setup, but subsequent modifications can be made using the knife.rb configuration file.
The following options can be run with all knife sub-commands and plug-ins:
Most data is entered using a text editor in JSON format, unless the --disable-editing option is entered as part of a command. (Encrypted data bags use YAML, which is a superset of JSON.) JSON is a common, language-independent data format that provides a simple text representation of arbitrary data structures. For more information about JSON, see http://www.json.org/ or http://en.wikipedia.org/wiki/JSON.
Some knife commands, such as knife data bag edit, require that information be edited as JSON data using a text editor. For example, the following command:
$ knife data bag edit admins admin_name
will open up the text editor with data similar to:
{
"id": "admin_name" }
Changes to that file can then be made:
{
"id": "Justin C."
"description": "I am passing the time by letting time pass over me ..." }
The type of text editor that is used by knife can be configured by adding an entry to the knife.rb file or by setting an EDITOR environment variable. For example, to configure the text editor to always open with vim, add the following to the knife.rb file:
knife[:editor] = "/usr/bin/vim"
When a Microsoft Windows file path is enclosed in a double-quoted string (" "), the same backslash character (\) that is used to define the file path separator is also used in Ruby to define an escape character. The knife.rb file is a Ruby file; therefore, file path separators must be escaped. In addition, spaces in the file path must be replaced with ~1 so that the length of each section within the file path is not more than 8 characters. For example, if EditPad Pro is the text editor of choice and is located at the following path:
C:\\Program Files (x86)\EditPad Pro\EditPad.exe
the setting in the knife.rb file would be similar to:
knife[:editor] = "C:\\Progra~1\\EditPa~1\\EditPad.exe"
One approach to working around the double- vs. single-quote issue is to put the single-quotes outside of the double-quotes. For example, for Notepad++:
knife[:editor] = '"C:\Program Files (x86)\Notepad++\notepad++.exe -nosession -multiInst"'
for Sublime Text:
knife[:editor] = '"C:\Program Files\Sublime Text 2\sublime_text.exe --wait"'
for TextPad:
knife[:editor] = '"C:\Program Files (x86)\TextPad 7\TextPad.exe"'
and for vim:
knife[:editor] = '"C:\Program Files (x86)\vim\vim74\gvim.exe"'
Values can be entered with double quotes (" ") or single quotes (' '), but this should be done consistently.
knife comes with a collection of built in subcommands that work together to provide all of the functionality required to take specific actions against any object in an organization, including cookbooks, nodes, roles, data bags, environments, and users. A knife plugin extends the functionality beyond built-in subcommands.
knife has the following subcommands: bootstrap, client, configure, cookbook, cookbook site, data bag, delete, deps, diff, download, edit, environment, exec, index rebuild, list, node, recipe list, role, search, show, ssh, status, tag, upload, user, and xargs.
NOTE:
All knife subcommands have the following syntax:
Each subcommand has its own set of arguments and options.
NOTE:
Chef
Chef 12.0 |