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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>knife cookbook — chef-client Man Pages</title>
<link rel="stylesheet" href="_static/guide.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="shortcut icon" href="_static/chef.ico"/>
</head>
<body>
<div style="background-color: #212c35; text-align: left; padding: 0px 0px 0px 0px">
<a href="http://docs.opscode.com/"><img src="_static/chef_html_logo.png" border="0" alt="Chef"/></a>
</div>
<div class="document">
<div class="documentwrapper">
<div class="body">
<div class="section" id="knife-cookbook">
<h1>knife cookbook<a class="headerlink" href="#knife-cookbook" title="Permalink to this headline">¶</a></h1>
<p>A cookbook is the fundamental unit of configuration and policy distribution. Each cookbook defines a scenario, such as everything needed to install and configure MySQL, and then it contains all of the components that are required to support that scenario, including:</p>
<ul class="simple">
<li>Attribute values that are set on nodes</li>
<li>Definitions that allow the creation of reusable collections of resources</li>
<li>File distributions</li>
<li>Libraries that extend the chef-client and/or provide helpers to Ruby code</li>
<li>Recipes that specify which resources to manage and the order in which those resources will be applied</li>
<li>Custom resources and providers</li>
<li>Templates</li>
<li>Versions</li>
<li>Metadata about recipes (including dependencies), version constraints, supported platforms, and so on</li>
</ul>
<p>The <strong>knife cookbook</strong> subcommand is used to interact with cookbooks that are located on the Chef server or the local chef-repo.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Review the list of <a class="reference internal" href="knife_common_options.html"><em>common options</em></a> available to this (and all) Knife subcommands and plugins.</p>
</div>
<div class="section" id="bulk-delete">
<h2>bulk delete<a class="headerlink" href="#bulk-delete" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">bulk</span> <span class="pre">delete</span></tt> argument is used to delete cookbook files that match a pattern defined by a regular expression. The regular expression must be within quotes and not be surrounded by forward slashes (/).</p>
<div class="section" id="syntax">
<h3>Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook bulk delete REGEX <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="options">
<h3>Options<a class="headerlink" href="#options" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">-p</span></tt>, <tt class="docutils literal"><span class="pre">--purge</span></tt></dt>
<dd>Indicates that a cookbook (or cookbook version) will be removed entirely from the Chef server. This action should be used carefully because only one copy of any single file is stored on the Chef server. Consequently, purging a cookbook will disable any other cookbook that references one or more files from a cookbook that has been purged.</dd>
</dl>
</div>
<div class="section" id="examples">
<h3>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>Bulk delete many cookbooks</strong></p>
<p>Use a regular expression to define the pattern used to bulk delete cookbooks:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook bulk delete <span class="s2">"^[0-9]{3}$"</span> -p
</pre></div>
</div>
</div>
</div>
<div class="section" id="create">
<h2>create<a class="headerlink" href="#create" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">create</span></tt> argument is used to create a new cookbook directory on the local machine, including the following directories and files:</p>
<blockquote>
<div><ul class="simple">
<li>cookbook/attributes</li>
<li>cookbook/CHANGELOG.md</li>
<li>cookbook/definitions</li>
<li>cookbook/files/default</li>
<li>cookbook/libraries</li>
<li>cookbook/metadata.rb</li>
<li>cookbook/providers</li>
<li>cookbook/README.md (or .rdoc)</li>
<li>cookbook/recipes/default.rb</li>
<li>cookbook/resources</li>
<li>cookbook/templates/default</li>
</ul>
</div></blockquote>
<p>After the cookbook is created, it can be uploaded to the Chef server using the <tt class="docutils literal"><span class="pre">knife</span> <span class="pre">upload</span></tt> argument.</p>
<div class="section" id="id1">
<h3>Syntax<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook create COOKBOOK_NAME <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id2">
<h3>Options<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">-C</span> <span class="pre">COPYRIGHT_HOLDER</span></tt>, <tt class="docutils literal"><span class="pre">--copyright</span> <span class="pre">COPYRIGHT_HOLDER</span></tt></dt>
<dd>The name of the copyright holder. This option will place a copyright notice that contains the name of the copyright holder in each of the pre-created files. If this option is not specified, a copyright name of “your_company_name” will be used instead; it can be easily modified later.</dd>
<dt><tt class="docutils literal"><span class="pre">-I</span> <span class="pre">LICENSE</span></tt>, <tt class="docutils literal"><span class="pre">--license</span> <span class="pre">LICENSE</span></tt></dt>
<dd>The type of license under which a cookbook is distributed: <tt class="docutils literal"><span class="pre">apachev2</span></tt>, <tt class="docutils literal"><span class="pre">gplv2</span></tt>, <tt class="docutils literal"><span class="pre">gplv3</span></tt>, <tt class="docutils literal"><span class="pre">mit</span></tt>, or <tt class="docutils literal"><span class="pre">none</span></tt> (default). This option will place the appropriate license notice in the pre-created files: <tt class="docutils literal"><span class="pre">Apache</span> <span class="pre">v2.0</span></tt> (for <tt class="docutils literal"><span class="pre">apachev2</span></tt>), <tt class="docutils literal"><span class="pre">GPL</span> <span class="pre">v2</span></tt> (for <tt class="docutils literal"><span class="pre">gplv2</span></tt>), <tt class="docutils literal"><span class="pre">GPL</span> <span class="pre">v3</span></tt> (for <tt class="docutils literal"><span class="pre">gplv3</span></tt>), <tt class="docutils literal"><span class="pre">MIT</span></tt> (for <tt class="docutils literal"><span class="pre">mit</span></tt>), or <tt class="docutils literal"><span class="pre">license</span> <span class="pre">'Proprietary</span> <span class="pre">-</span> <span class="pre">All</span> <span class="pre">Rights</span> <span class="pre">Reserved</span></tt> (for <tt class="docutils literal"><span class="pre">none</span></tt>). Be aware of the licenses for files inside of a cookbook and be sure to follow any restrictions they describe.</dd>
<dt><tt class="docutils literal"><span class="pre">-m</span> <span class="pre">EMAIL</span></tt>, <tt class="docutils literal"><span class="pre">--email</span> <span class="pre">EMAIL</span></tt></dt>
<dd>The email address for the individual who maintains the cookbook. This option will place an email address in each of the pre-created files. If this option is not specified, an email name of “your_email” will be used instead; it can be easily modified later.</dd>
<dt><tt class="docutils literal"><span class="pre">-o</span> <span class="pre">PATH</span></tt>, <tt class="docutils literal"><span class="pre">--cookbook-path</span> <span class="pre">PATH</span></tt></dt>
<dd>The directory in which cookbook are created. This can be a colon-separated path.</dd>
<dt><tt class="docutils literal"><span class="pre">-r</span> <span class="pre">FORMAT</span></tt>, <tt class="docutils literal"><span class="pre">--readme-format</span> <span class="pre">FORMAT</span></tt></dt>
<dd>The document format of the readme file: <tt class="docutils literal"><span class="pre">md</span></tt> (markdown) and <tt class="docutils literal"><span class="pre">rdoc</span></tt> (Ruby docs).</dd>
</dl>
</div>
<div class="section" id="id3">
<h3>Examples<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>Create a cookbook</strong></p>
<p>To create a cookbook named “my_cookbook” with copyright, email, license, and readme format options specified, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook create my_cookbook -C <span class="s2">"My Name"</span> -m <span class="s2">"my@email.com"</span> -I apachev2 -r md
</pre></div>
</div>
<p>to return something like:</p>
<div class="highlight-bash"><div class="highlight"><pre>** Creating cookbook my_cookbook
** Creating README <span class="k">for </span>cookbook: my_cookbook
** Creating metadata <span class="k">for </span>cookbook: my_cookbook
</pre></div>
</div>
</div>
</div>
<div class="section" id="delete">
<h2>delete<a class="headerlink" href="#delete" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">delete</span></tt> argument is used to delete a specified cookbook or cookbook version on the Chef server (and not locally).</p>
<div class="section" id="id4">
<h3>Syntax<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook delete COOKBOOK_NAME <span class="o">[</span>COOKBOOK_VERSION<span class="o">]</span> <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id5">
<h3>Options<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">-a</span></tt>, <tt class="docutils literal"><span class="pre">--all</span></tt></dt>
<dd>Indicates that a cookbook and every version of that cookbook will be deleted.</dd>
<dt><tt class="docutils literal"><span class="pre">COOKBOOK_VERSION</span></tt></dt>
<dd>The version of a cookbook to be deleted. If a cookbook has only one version, this option does not need to be specified. If a cookbook has more than one version and this option is not specified, Knife will prompt for a version.</dd>
<dt><tt class="docutils literal"><span class="pre">-p</span></tt>, <tt class="docutils literal"><span class="pre">--purge</span></tt></dt>
<dd>Indicates that a cookbook (or cookbook version) will be removed entirely from the Chef server. This action should be used carefully because only one copy of any single file is stored on the Chef server. Consequently, purging a cookbook will disable any other cookbook that references one or more files from a cookbook that has been purged.</dd>
</dl>
</div>
<div class="section" id="id6">
<h3>Examples<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>Delete a cookbook</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook delete cookbook_name version
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook delete smartmon 0.8
</pre></div>
</div>
<p>Type <tt class="docutils literal"><span class="pre">Y</span></tt> to confirm a deletion.</p>
</div>
</div>
<div class="section" id="download">
<h2>download<a class="headerlink" href="#download" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">download</span></tt> argument is used to download a cookbook from the Chef server to the current working directory.</p>
<div class="section" id="id7">
<h3>Syntax<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook download COOKBOOK_NAME <span class="o">[</span>COOKBOOK_VERSION<span class="o">]</span> <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id8">
<h3>Options<a class="headerlink" href="#id8" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">-d</span> <span class="pre">DOWNLOAD_DIRECTORY</span></tt>, <tt class="docutils literal"><span class="pre">--dir</span> <span class="pre">DOWNLOAD_DIRECTORY</span></tt></dt>
<dd>The directory into which a cookbook will be downloaded.</dd>
<dt><tt class="docutils literal"><span class="pre">-f</span></tt>, <tt class="docutils literal"><span class="pre">--force</span></tt></dt>
<dd>Indicates that an existing directory will be overwritten.</dd>
<dt><tt class="docutils literal"><span class="pre">-N</span></tt>, <tt class="docutils literal"><span class="pre">--latest</span></tt></dt>
<dd>Indicates that the most recent version of a cookbook will be downloaded.</dd>
</dl>
</div>
<div class="section" id="id9">
<h3>Examples<a class="headerlink" href="#id9" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>Download a cookbook</strong></p>
<p>To download a cookbook named “smartmon”, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook download smartmon
</pre></div>
</div>
</div>
</div>
<div class="section" id="list">
<h2>list<a class="headerlink" href="#list" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">list</span></tt> argument is used to view a list of cookbooks that are currently available on the Chef server. The list will contain only the most recent version for each cookbook by default.</p>
<div class="section" id="id10">
<h3>Syntax<a class="headerlink" href="#id10" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook list <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id11">
<h3>Options<a class="headerlink" href="#id11" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">-a</span></tt>, <tt class="docutils literal"><span class="pre">--all</span></tt></dt>
<dd>Indicates that all available versions of each cookbook will be returned.</dd>
<dt><tt class="docutils literal"><span class="pre">-w</span></tt>, <tt class="docutils literal"><span class="pre">--with-uri</span></tt></dt>
<dd>Indicates that the corresponding URIs will be shown.</dd>
</dl>
</div>
<div class="section" id="id12">
<h3>Examples<a class="headerlink" href="#id12" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>View a list of cookbooks</strong></p>
<p>To view a list of cookbooks:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook list
</pre></div>
</div>
</div>
</div>
<div class="section" id="metadata">
<h2>metadata<a class="headerlink" href="#metadata" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">metadata</span></tt> argument is used to generate the metadata for one or more cookbooks.</p>
<div class="section" id="id13">
<h3>Syntax<a class="headerlink" href="#id13" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook metadata <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id14">
<h3>Options<a class="headerlink" href="#id14" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">-a</span></tt>, <tt class="docutils literal"><span class="pre">--all</span></tt></dt>
<dd>Indicates that metadata should be generated for all cookbooks, and not just for a specified cookbook.</dd>
<dt><tt class="docutils literal"><span class="pre">-o</span> <span class="pre">PATH:PATH</span></tt>, <tt class="docutils literal"><span class="pre">--cookbook-path</span> <span class="pre">PATH:PATH</span></tt></dt>
<dd>The directory in which cookbook are created. This can be a colon-separated path.</dd>
</dl>
</div>
<div class="section" id="id15">
<h3>Examples<a class="headerlink" href="#id15" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>Generate metadata</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook metadata -a
</pre></div>
</div>
</div>
</div>
<div class="section" id="metadata-from-file">
<h2>metadata from file<a class="headerlink" href="#metadata-from-file" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">metadata</span> <span class="pre">from</span> <span class="pre">file</span></tt> argument is used to load the metadata for a cookbook from a file.</p>
<div class="section" id="id16">
<h3>Syntax<a class="headerlink" href="#id16" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook metadata from file FILE
</pre></div>
</div>
</div>
<div class="section" id="id17">
<h3>Options<a class="headerlink" href="#id17" title="Permalink to this headline">¶</a></h3>
<p>This command does not have any specific options.</p>
</div>
<div class="section" id="id18">
<h3>Examples<a class="headerlink" href="#id18" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>View metadata</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook metadta from file /path/to/file
</pre></div>
</div>
</div>
</div>
<div class="section" id="show">
<h2>show<a class="headerlink" href="#show" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">show</span></tt> argument is used to view information about a cookbook, parts of a cookbook (attributes, definitions, files, libraries, providers, recipes, resources, and templates), or a file that is associated with a cookbook (including attributes such as checksum or specificity).</p>
<div class="section" id="id19">
<h3>Syntax<a class="headerlink" href="#id19" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook show COOKBOOK_NAME <span class="o">[</span>COOKBOOK_VERSION<span class="o">]</span> <span class="o">[</span>PART...<span class="o">]</span> <span class="o">[</span>FILE_NAME<span class="o">]</span> <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id20">
<h3>Options<a class="headerlink" href="#id20" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">COOKBOOK_VERSION</span></tt></dt>
<dd>The version of a cookbook to be shown. If a cookbook has only one version, this option does not need to be specified. If a cookbook has more than one version and this option is not specified, a list of cookbook versions will be returned.</dd>
<dt><tt class="docutils literal"><span class="pre">-f</span> <span class="pre">FQDN</span></tt>, <tt class="docutils literal"><span class="pre">--fqdn</span> <span class="pre">FQDN</span></tt></dt>
<dd>The FQDN of the host.</dd>
<dt><tt class="docutils literal"><span class="pre">FILE_NAME</span></tt></dt>
<dd>The name of a file that is associated with a cookbook.</dd>
<dt><tt class="docutils literal"><span class="pre">-p</span> <span class="pre">PLATFORM</span></tt>, <tt class="docutils literal"><span class="pre">--platform</span> <span class="pre">PLATFORM</span></tt></dt>
<dd>The platform for which a cookbook is designed.</dd>
<dt><tt class="docutils literal"><span class="pre">PART</span></tt></dt>
<dd>The part of the cookbook to show: <tt class="docutils literal"><span class="pre">attributes</span></tt>, <tt class="docutils literal"><span class="pre">definitions</span></tt>, <tt class="docutils literal"><span class="pre">files</span></tt>, <tt class="docutils literal"><span class="pre">libraries</span></tt>, <tt class="docutils literal"><span class="pre">providers</span></tt>, <tt class="docutils literal"><span class="pre">recipes</span></tt>, <tt class="docutils literal"><span class="pre">resources</span></tt>, or <tt class="docutils literal"><span class="pre">templates</span></tt>. More than one part can be specified.</dd>
<dt><tt class="docutils literal"><span class="pre">-V</span> <span class="pre">PLATFORM_VERSION</span></tt>, <tt class="docutils literal"><span class="pre">--platform-version</span> <span class="pre">PLATFORM_VERSION</span></tt></dt>
<dd>The version of the platform.</dd>
<dt><tt class="docutils literal"><span class="pre">-w</span></tt>, <tt class="docutils literal"><span class="pre">--with-uri</span></tt></dt>
<dd>Indicates that the corresponding URIs will be shown.</dd>
</dl>
</div>
<div class="section" id="id21">
<h3>Examples<a class="headerlink" href="#id21" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>Show cookbook data</strong></p>
<p>To get the list of available versions of a cookbook named “getting-started”, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook show getting-started
</pre></div>
</div>
<p>to return something like:</p>
<div class="highlight-bash"><div class="highlight"><pre>getting-started 0.3.0 0.2.0
</pre></div>
</div>
<p><strong>Show cookbook versions</strong></p>
<p>To show a list of data about a cookbook using the name of the cookbook and the version, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook show getting-started 0.3.0
</pre></div>
</div>
<p>to return something like:</p>
<div class="highlight-bash"><div class="highlight"><pre>attributes:
checksum: fa0fc4abf3f6787aeb5c3c5c35de667c
name: default.rb
path: attributes/default.rb
specificity: default
url: https://somelongurlhere.com
chef_type: cookbook_version
cookbook_name: getting-started
definitions: <span class="o">[]</span>
files: <span class="o">[]</span>
frozen?: <span class="nb">false</span>
json_class: Chef::CookbookVersion
libraries: <span class="o">[]</span>
</pre></div>
</div>
<p><strong>Show a cookbook version</strong></p>
<p>To only view data about “templates”, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook show getting-started 0.3.0 templates
</pre></div>
</div>
<p>to return something like:</p>
<div class="highlight-bash"><div class="highlight"><pre>checksum: a29d6f254577b830091f140c3a78b1fe
name: chef-getting-started.txt.erb
path: templates/default/chef-getting-started.txt.erb
specificity: default
url: https://someurlhere.com
</pre></div>
</div>
<p><strong>Show cookbook data as JSON</strong></p>
<p>To view information in JSON format, use the <tt class="docutils literal"><span class="pre">-F</span></tt> common option as part of the command like this:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife role show devops -F json
</pre></div>
</div>
<p>Other formats available include <tt class="docutils literal"><span class="pre">text</span></tt>, <tt class="docutils literal"><span class="pre">yaml</span></tt>, and <tt class="docutils literal"><span class="pre">pp</span></tt>.</p>
</div>
</div>
<div class="section" id="test">
<h2>test<a class="headerlink" href="#test" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">test</span></tt> argument is used to test a cookbook for syntax errors. This argument uses Ruby syntax checking to verify every file in a cookbook that ends in .rb and Embedded Ruby (ERB).</p>
<div class="section" id="id22">
<h3>Syntax<a class="headerlink" href="#id22" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook <span class="nb">test </span>COOKBOOK_NAME <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id23">
<h3>Options<a class="headerlink" href="#id23" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">-a</span></tt>, <tt class="docutils literal"><span class="pre">--all</span></tt></dt>
<dd>Indicates that all cookbooks will be tested.</dd>
<dt><tt class="docutils literal"><span class="pre">-o</span> <span class="pre">PATH:PATH</span></tt>, <tt class="docutils literal"><span class="pre">--cookbook-path</span> <span class="pre">PATH:PATH</span></tt></dt>
<dd>The directory in which cookbook are created. This can be a colon-separated path.</dd>
</dl>
</div>
<div class="section" id="id24">
<h3>Examples<a class="headerlink" href="#id24" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>Test a cookbook</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook <span class="nb">test </span>cookbook_name
</pre></div>
</div>
</div>
</div>
<div class="section" id="upload">
<h2>upload<a class="headerlink" href="#upload" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">upload</span></tt> argument is used to upload one or more cookbooks (and any files that are associated with those cookbooks) from a local repository to the Chef server. Only files that do not already exist on the Chef server will be uploaded.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Use a .chefignore file to prevent the upload of specific files and file types, such as temporary files or files placed in folders by version control systems. The .chefignore file must be located in the root of the cookbook repository and must use rules similar to filename globbing (as defined by the Ruby <tt class="docutils literal"><span class="pre">File.fnmatch</span></tt> syntax).</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Empty directories are not uploaded to the Chef server. To upload an empty directory, create a “dot” file—e.g. <tt class="docutils literal"><span class="pre">.keep</span></tt>—in that directory to ensure that the directory itself is not empty.</p>
</div>
<div class="section" id="id25">
<h3>Syntax<a class="headerlink" href="#id25" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following syntax:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook upload <span class="o">[</span>COOKBOOK_NAME...<span class="o">]</span> <span class="o">(</span>options<span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="id26">
<h3>Options<a class="headerlink" href="#id26" title="Permalink to this headline">¶</a></h3>
<p>This argument has the following options:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">-a</span></tt>, <tt class="docutils literal"><span class="pre">--all</span></tt></dt>
<dd>Indicates that all cookbooks will be uploaded.</dd>
<dt><tt class="docutils literal"><span class="pre">--concurrency</span></tt></dt>
<dd>The number of allowed concurrent connections. Default: <tt class="docutils literal"><span class="pre">10</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">-d</span></tt>, <tt class="docutils literal"><span class="pre">--include-dependencies</span></tt></dt>
<dd>Indicates that when a cookbook has a dependency on one (or more) cookbooks, those cookbooks will also be uploaded.</dd>
<dt><tt class="docutils literal"><span class="pre">-E</span> <span class="pre">ENVIRONMENT</span></tt>, <tt class="docutils literal"><span class="pre">--environment</span> <span class="pre">ENVIRONMENT</span></tt></dt>
<dd>Use to set the environment version dependency to the cookbook version being uploaded.</dd>
<dt><tt class="docutils literal"><span class="pre">--force</span></tt></dt>
<dd>Indicates that a cookbook should be updated even if the <tt class="docutils literal"><span class="pre">--freeze</span></tt> flag has been set.</dd>
<dt><tt class="docutils literal"><span class="pre">--freeze</span></tt></dt>
<dd>Indicates that a cookbook cannot be modified; any changes to this cookbook must be included as a new version. Only the <tt class="docutils literal"><span class="pre">--force</span></tt> option can override this setting.</dd>
<dt><tt class="docutils literal"><span class="pre">-o</span> <span class="pre">PATH:PATH</span></tt>, <tt class="docutils literal"><span class="pre">--cookbook-path</span> <span class="pre">PATH:PATH</span></tt></dt>
<dd>The directory in which cookbook are created. This can be a colon-separated path.</dd>
</dl>
</div>
<div class="section" id="id27">
<h3>Examples<a class="headerlink" href="#id27" title="Permalink to this headline">¶</a></h3>
<p>The following examples show how to use this Knife subcommand:</p>
<p><strong>Upload a cookbook</strong></p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook upload cookbook_name
</pre></div>
</div>
<p><strong>Freeze a cookbook</strong></p>
<p>To upload a cookbook, and then prevent other users from being able to make changes to it, enter:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife cookbook upload redis --freeze
</pre></div>
</div>
<p>to return something like:</p>
<div class="highlight-bash"><div class="highlight"><pre>Uploading redis...
Upload completed
</pre></div>
</div>
<p>If a cookbook is frozen and the <tt class="docutils literal"><span class="pre">--force</span></tt> option is not specified, Knife will return an error message similar to the following:</p>
<div class="highlight-bash"><div class="highlight"><pre>Uploading redis...
ERROR: Version 0.1.6 of cookbook redis is frozen. Use --force to override.
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</body>
</html>
|