1. knife-cookbook(1)
  2. Chef Manual
  3. knife-cookbook(1)

NAME

knife-cookbook - Upload and manage Chef cookbooks

SYNOPSIS

knife cookbook sub-command (options)

COOKBOOK SUB-COMMANDS

Cookbooks are the fundamental unit of distribution in Chef. They encapsulate all recipes of resources and assets used to configure a particular aspect of the infrastructure. The following sub-commands can be used to manipulate the cookbooks stored on the Chef Server.

cookbook bulk delete REGEX (options)

-p, --purge
Purge files from backing store. This will disable any cookbook that contains any of the same files as the cookbook being purged.

Delete cookbooks on the Chef Server based on a regular expression. The regular expression (REGEX) should be in quotes, not in //'s.

cookbook create COOKBOOK (options)

-o, --cookbook-path PATH
The directory where the cookbook will be created
-r, --readme-format FORMAT
Format of the README file
-C, --copyright COPYRIGHT
Name of Copyright holder
-I, --license LICENSE
License for cookbook, apachev2 or none
-E, --email EMAIL
Email address of cookbook maintainer

This is a helper command that creates a new cookbook directory in the cookbook_path. The following directories and files are created for the named cookbook.

Supported README formats are 'rdoc' (default), 'md', 'mkd', 'txt'. The README file will be written with the specified extension and a set of helpful starting headers.

Specify -C or --copyright with the name of the copyright holder as your name or your company/organization name in a quoted string. If this value is not specified an all-caps string YOUR_COMPANY_NAME is used which can be easily changed with find/replace.

Specify -I or --license with the license that the cookbook is distributed under for sharing with other people or posting to the Opscode Cookbooks site. Be aware of the licenses of files you put inside the cookbook and follow any restrictions they describe. When using none (default) or apachev2, comment header text and metadata file are pre-filled. The none license will be treated as non-redistributable.

Specify -E or --email with the email address of the cookbook's maintainer. If this value is not specified, an all-caps string YOUR_EMAIL is used which can easily be changed with find/replace.

The cookbook copyright, license and email settings can be filled in the knife.rb, for example with default values:

cookbook_copyright "YOUR_COMPANY_NAME"
cookbook_license "none"
cookbook_email "YOUR_EMAIL"

cookbook delete COOKBOOK [VERSION] (options)

-a, --all
Delete all versions
-p, --purge
Purge files from backing store. This will disable any cookbook that contains any of the same files as the cookbook being purged.

Delete the specified VERSION of the named COOKBOOK. If no version is specified, and only one version exists on the server, that version will be deleted. If multiple versions are available on the server, you will be prompted for a version to delete.

cookbook download COOKBOOK [VERSION] (options)

-d, --dir DOWNLOAD_DIRECTORY
The directory to download the cookbook into
-f, --force
Overwrite an existing directory with the download
-N, --latest
Download the latest version of the cookbook

Download a cookbook from the Chef Server. If no version is specified and only one version exists on the server, that version will be downloaded. If no version is specified and multiple versions are available on the server, you will be prompted for a version to download.

cookbook list (options)

-w, --with-uri
Show corresponding URIs

List all the cookbooks.

cookbook metadata COOKBOOK (options)

-a, --all
Generate metadata for all cookbooks, rather than just a single cookbook
-o, --cookbook-path PATH:PATH
A colon-separated path to look for cookbooks in

Generate cookbook metadata for the named COOKBOOK. The PATH used here specifies where the cookbooks directory is located and corresponds to the cookbook_path configuration option.

cookbook metadata from FILE (options)

Load the cookbook metadata from a specified file.

cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)

-f, --fqdn FQDN
The FQDN of the host to see the file for
-p, --platform PLATFORM
The platform to see the file for
-V, --platform-version VERSION
The platform version to see the file for

Show a particular part of a COOKBOOK for the specified VERSION. PART can be one of:

cookbook test [COOKBOOKS...] (options)

-a, --all
Test all cookbooks, rather than just a single cookbook
-o, --cookbook-path PATH:PATH
A colon-separated path to look for cookbooks in

Test the specified cookbooks for syntax errors. This uses the built-in Ruby syntax checking option for files in the cookbook ending in .rb, and the ERB syntax check for files ending in .erb (templates).

cookbook upload [COOKBOOKS...] (options)

-a, --all
Upload all cookbooks, rather than just a single cookbook
-o, --cookbook-path PATH:PATH
A colon-separated path to look for cookbooks in

Uploads the specified cookbooks to the Chef Server. The actual upload executes a number of commands, most of which occur on the local machine. The cookbook is staged in a temporary location. Then the cookbook_path (or -o PATH) is processed to search for the named cookbook, and each occurance is copied in the order specified. A syntax check is performed a la cookbook test, above. The metadata is generated, a la cookbook metadata. A gzip(1)'ed, tar(1) file is created, and is uploaded to the server.

  1. Chef 0.10.0.beta.8
  2. April 2011
  3. knife-cookbook(1)