|
| 1 | +knife-cookbook(8) -- Chef Server REST API utility |
| 2 | +======================================== |
| 3 | + |
| 4 | +## SYNOPSIS |
| 5 | + |
| 6 | +__knife__ __cookbook__ _sub-command_ _(options)_ |
| 7 | + |
| 8 | +## COOKBOOK SUB-COMMANDS |
| 9 | + |
| 10 | +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. |
| 11 | + |
| 12 | +__cookbook bulk delete REGEX__ _(options)_ |
| 13 | + |
| 14 | + * `-p`, `--purge`: |
| 15 | + Purge files from backing store. This will disable any cookbook that contains any of the same files as the cookbook being purged. |
| 16 | + |
| 17 | +Delete cookbooks on the Chef Server based on a regular expression. The regular expression (_REGEX_) should be in quotes, not in //'s. |
| 18 | + |
| 19 | +__cookbook create COOKBOOK__ _(options)_ |
| 20 | + |
| 21 | + * `-o`, `--cookbook-path PATH`: |
| 22 | + The directory where the cookbook will be created |
| 23 | + * `-r`, `--readme-format FORMAT`: |
| 24 | + Format of the README file |
| 25 | + * `-C`, `--copyright COPYRIGHT`: |
| 26 | + Name of Copyright holder |
| 27 | + * `-I`, `--license LICENSE`: |
| 28 | + License for cookbook, apachev2 or none |
| 29 | + * `-E`, `--email EMAIL`: |
| 30 | + Email address of cookbook maintainer |
| 31 | + |
| 32 | +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. |
| 33 | + |
| 34 | +* COOKBOOK/attributes |
| 35 | +* COOKBOOK/definitions |
| 36 | +* COOKBOOK/files/default |
| 37 | +* COOKBOOK/libraries |
| 38 | +* COOKBOOK/metadata.rb |
| 39 | +* COOKBOOK/providers |
| 40 | +* COOKBOOK/README.rdoc |
| 41 | +* COOKBOOK/recipes/default.rb |
| 42 | +* COOKBOOK/resources |
| 43 | +* COOKBOOK/templates/default |
| 44 | + |
| 45 | +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. |
| 46 | + |
| 47 | +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. |
| 48 | + |
| 49 | +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. |
| 50 | + |
| 51 | +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. |
| 52 | + |
| 53 | +The cookbook copyright, license and email settings can be filled in the `knife.rb`, for example with default values: |
| 54 | + |
| 55 | + cookbook_copyright "YOUR_COMPANY_NAME" |
| 56 | + cookbook_license "none" |
| 57 | + cookbook_email "YOUR_EMAIL" |
| 58 | + |
| 59 | +__cookbook delete COOKBOOK [VERSION]__ _(options)_ |
| 60 | + |
| 61 | + * `-a`, `--all`: |
| 62 | + Delete all versions |
| 63 | + * `-p`, `--purge`: |
| 64 | + Purge files from backing store. This will disable any cookbook that contains any of the same files as the cookbook being purged. |
| 65 | + |
| 66 | +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. |
| 67 | + |
| 68 | +__cookbook download COOKBOOK [VERSION]__ _(options)_ |
| 69 | + |
| 70 | + * `-d`, `--dir DOWNLOAD_DIRECTORY`: |
| 71 | + The directory to download the cookbook into |
| 72 | + * `-f`, `--force`: |
| 73 | + Overwrite an existing directory with the download |
| 74 | + * `-N`, `--latest`: |
| 75 | + Download the latest version of the cookbook |
| 76 | + |
| 77 | +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. |
| 78 | + |
| 79 | +__cookbook list__ _(options)_ |
| 80 | + |
| 81 | + * `-w`, `--with-uri`: |
| 82 | + Show corresponding URIs |
| 83 | + |
| 84 | +List all the cookbooks. |
| 85 | + |
| 86 | +__cookbook metadata COOKBOOK__ _(options)_ |
| 87 | + |
| 88 | + * `-a`, `--all`: |
| 89 | + Generate metadata for all cookbooks, rather than just a single cookbook |
| 90 | + * `-o`, `--cookbook-path PATH:PATH`: |
| 91 | + A colon-separated path to look for cookbooks in |
| 92 | + |
| 93 | +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. |
| 94 | + |
| 95 | +__cookbook metadata from FILE__ _(options)_ |
| 96 | + |
| 97 | +Load the cookbook metadata from a specified file. |
| 98 | + |
| 99 | +__cookbook show COOKBOOK [VERSION] [PART] [FILENAME]__ _(options)_ |
| 100 | + |
| 101 | + * `-f`, `--fqdn FQDN `: |
| 102 | + The FQDN of the host to see the file for |
| 103 | + * `-p`, `--platform PLATFORM `: |
| 104 | + The platform to see the file for |
| 105 | + * `-V`, `--platform-version VERSION`: |
| 106 | + The platform version to see the file for |
| 107 | + |
| 108 | +Show a particular part of a _COOKBOOK_ for the specified _VERSION_. _PART_ can be one of: |
| 109 | + |
| 110 | + * _attributes_ |
| 111 | + * _definitions_ |
| 112 | + * _files_ |
| 113 | + * _libraries_ |
| 114 | + * _providers_ |
| 115 | + * _recipes_ |
| 116 | + * _resources_ |
| 117 | + * _templates_ |
| 118 | + |
| 119 | +__cookbook test [COOKBOOKS...]__ _(options)_ |
| 120 | + |
| 121 | + * `-a`, `--all`: |
| 122 | + Test all cookbooks, rather than just a single cookbook |
| 123 | + * `-o`, `--cookbook-path PATH:PATH`: |
| 124 | + A colon-separated path to look for cookbooks in |
| 125 | + |
| 126 | +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). |
| 127 | + |
| 128 | +__cookbook upload [COOKBOOKS...]__ _(options)_ |
| 129 | + |
| 130 | + * `-a`, `--all`: |
| 131 | + Upload all cookbooks, rather than just a single cookbook |
| 132 | + * `-o`, `--cookbook-path PATH:PATH`: |
| 133 | + A colon-separated path to look for cookbooks in |
| 134 | + |
| 135 | +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. |
| 136 | + |
0 commit comments