1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
knife-cookbook(1) -- upload and manage chef cookbooks
========================================
## SYNOPSIS
__knife__ __cookbook__ _sub-command_ _(options)_
## SUB-COMMANDS
`knife cookbook` supports the following sub commands:
## LIST
__knife cookbook list__ _(options)_
* `-a`, `--all`:
show all versions of a cookbook instead of just the most recent
* `-w`, `--with-uri`:
show corresponding uris
Lists the cookbooks available on the Chef server.
## SHOW
__knife 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
* `-w`, `--with-uri`:
Show corresponding URIs
show a particular part of a _cookbook_ for the specified _version_. _part_ can be one of:
* _attributes_
* _definitions_
* _files_
* _libraries_
* _providers_
* _recipes_
* _resources_
* _templates_
## UPLOAD
__knife 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
* `-d`, `--upload-dependencies`:
Uploads additional cookbooks that this cookbook lists in as
dependencies in its metadata.
* `-E`, `--environment ENVIRONMENT`:
An _ENVIRONMENT_ to apply the uploaded cookbooks to. Specifying this
option will cause knife to edit the _ENVIRONMENT_ to place a strict
version constraint on the cookbook version(s) uploaded.
* `--freeze`:
Sets the frozen flag on the uploaded cookbook(s) Any future attempt
to modify the cookbook without changing the version number will
return an error unless --force is specified.
* `--force`:
Overrides the frozen flag on a cookbook, allowing you to overwrite a
cookbook version that has previously been uploaded with the --freeze
option.
Uploads one or more cookbooks from your local cookbook repository(ies)
to the Chef Server. Only files that don't yet exist on the server will
be uploaded.
As the command parses the name args as 1..n cookbook names:
`knife cookbook upload COOKBOOK COOKBOOK ...`
works for one to many cookbooks.
## DOWNLOAD
__knife 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.
## DELETE
__knife 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.
## BULK DELETE
__knife 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
__knife 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 md, mkd, txt, rdoc
* `-C`, `--copyright copyright`:
name of copyright holder
* `-i`, `--license license`:
license for cookbook, apachev2 or none
* `-m`, `--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.
* cookbook/attributes
* cookbook/definitions
* cookbook/files/default
* cookbook/libraries
* cookbook/metadata.rb
* cookbook/providers
* cookbook/readme.md
* cookbook/recipes/default.rb
* cookbook/resources
* cookbook/templates/default
supported readme formats are 'md' (default), 'mkd', 'txt', 'rdoc'. 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 `-m` 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, email and readme_format 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"
readme_format "md"
## METADATA
__knife 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.
## METADATA FROM FILE
__knife cookbook metadata from file__ _(options)_
load the cookbook metadata from a specified file.
## TEST
__knife 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).
## RECIPE LIST
__knife recipe list [PATTERN]__
List available recipes from the server. Specify _PATTERN_ as a regular
expression to limit the results.
## DESCRIPTION
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.
On disk, cookbooks are directories with a defined structure. The
following directories may appear within a cookbook:
* COOKBOOK/attributes/:
Ruby files that define default parameters to be used in recipes
* COOKBOOK/definitions/:
Ruby files that contain _resource definitions_
* COOKBOOK/files/SPECIFICITY:
Files of arbitrary type. These files may be downloaded by
chef-client(8) when configuring a host.
* COOKBOOK/libraries/:
Ruby files that contain library code needed for recipes
* COOKBOOK/providers/:
Ruby files that contain Lightweight Provider definitions
* COOKBOOK/recipes/:
Ruby files that use Chef's recipe DSL to describe the desired
configuration of a system
* COOKBOOK/resources/:
Ruby files that contain Lightweight Resource definitions
* COOKBOOK/templates/SPECIFICITY:
ERuby (ERb) template files. These are referenced by _recipes_ and
evaluated to dynamically generate configuration files.
__SPECIFICITY__ is a feature of _files_ and _templates_ that allow you
to specify alternate files to be used on a specific OS platform or host.
The default specificity setting is _default_, that is files in
`COOKBOOK/files/default` will be used when a more specific copy is not
available. Further documentation for this feature is available on the
Chef wiki: <http://wiki.opscode.com/display/chef/File+Distribution#FileDistribution-FileSpecificity>
Cookbooks also contain a metadata file that defines various properties
of the cookbook. The most important of these are the _version_ and the
_dependencies_. The _version_ is used in combination with environments
to select which copy of a given cookbook is distributed to a node. The
_dependencies_ are used by the server to determine which additional
cookbooks must be distributed to a given host when it requires a
cookbook.
## SEE ALSO
__knife-environment(1)__ __knife-cookbook-site(1)__
<http://wiki.opscode.com/display/chef/Cookbooks>
<http://wiki.opscode.com/display/chef/Metadata>
## AUTHOR
Chef was written by Adam Jacob <adam@opscode.com> with many contributions from the community.
## DOCUMENTATION
This manual page was written by Joshua Timberman <joshua@opscode.com>.
Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.
## CHEF
Knife is distributed with Chef. <http://wiki.opscode.com/display/chef/Home>
|