chef 0.10.0.beta.7 → 0.10.0.beta.8
Sign up to get free protection for your applications and to get access to all the features.
- data/distro/common/html/knife-bootstrap.1.html +182 -0
- data/distro/common/html/knife-client.1.html +216 -0
- data/distro/common/html/knife-configure.1.html +170 -0
- data/distro/common/html/knife-cookbook-site.1.html +166 -0
- data/distro/common/html/knife-cookbook.1.html +233 -0
- data/distro/common/html/knife-data-bag.1.html +234 -0
- data/distro/common/html/knife-environment.1.html +93 -0
- data/distro/common/html/knife-exec.1.html +93 -0
- data/distro/common/html/knife-index.1.html +125 -0
- data/distro/common/html/knife-node.1.html +268 -0
- data/distro/common/html/knife-recipe.1.html +92 -0
- data/distro/common/html/knife-role.1.html +136 -0
- data/distro/common/html/knife-search.1.html +102 -0
- data/distro/common/html/knife-ssh.1.html +101 -0
- data/distro/common/html/knife-status.1.html +97 -0
- data/distro/common/html/knife-tag.1.html +93 -0
- data/distro/common/html/knife.1.html +362 -0
- data/distro/common/man/man1/knife-bootstrap.1 +137 -0
- data/distro/common/man/man1/knife-client.1 +98 -0
- data/distro/common/man/man1/knife-configure.1 +88 -0
- data/distro/common/man/man1/knife-cookbook-site.1 +91 -0
- data/distro/common/man/man1/knife-cookbook.1 +242 -0
- data/distro/common/man/man1/knife-data-bag.1 +130 -0
- data/distro/common/man/man1/knife-environment.1 +13 -0
- data/distro/common/man/man1/knife-exec.1 +13 -0
- data/distro/common/man/man1/knife-index.1 +29 -0
- data/distro/common/man/man1/knife-node.1 +153 -0
- data/distro/common/man/man1/knife-recipe.1 +13 -0
- data/distro/common/man/man1/knife-role.1 +64 -0
- data/distro/common/man/man1/knife-search.1 +37 -0
- data/distro/common/man/man1/knife-ssh.1 +33 -0
- data/distro/common/man/man1/knife-status.1 +17 -0
- data/distro/common/man/man1/knife-tag.1 +13 -0
- data/distro/common/man/man1/knife.1 +346 -0
- data/distro/common/man/{man8/shef.8 → man1/shef.1} +0 -0
- data/distro/common/man/{man1/chef-server-webui.1 → man8/chef-server-webui.8} +0 -0
- data/distro/common/man/{man1/chef-server.1 → man8/chef-server.8} +0 -0
- data/distro/common/man/{man1/chef-solr.1 → man8/chef-solr.8} +0 -0
- data/distro/common/markdown/man1/knife-bootstrap.mkd +88 -0
- data/distro/common/markdown/man1/knife-client.mkd +101 -0
- data/distro/common/markdown/man1/knife-configure.mkd +70 -0
- data/distro/common/markdown/man1/knife-cookbook-site.mkd +69 -0
- data/distro/common/markdown/man1/knife-cookbook.mkd +136 -0
- data/distro/common/markdown/man1/knife-data-bag.mkd +117 -0
- data/distro/common/markdown/man1/knife-environment.mkd +8 -0
- data/distro/common/markdown/man1/knife-exec.mkd +9 -0
- data/distro/common/markdown/man1/knife-index.mkd +30 -0
- data/distro/common/markdown/man1/knife-node.mkd +147 -0
- data/distro/common/markdown/man1/knife-recipe.mkd +24 -0
- data/distro/common/markdown/man1/knife-role.mkd +79 -0
- data/distro/common/markdown/man1/knife-search.mkd +56 -0
- data/distro/common/markdown/man1/knife-ssh.mkd +64 -0
- data/distro/common/markdown/man1/knife-status.mkd +38 -0
- data/distro/common/markdown/man1/knife-tag.mkd +8 -0
- data/distro/common/markdown/man1/knife.mkd +261 -0
- data/lib/chef/cookbook/metadata.rb +76 -40
- data/lib/chef/cookbook_version.rb +86 -2
- data/lib/chef/cookbook_version_selector.rb +7 -2
- data/lib/chef/environment.rb +41 -0
- data/lib/chef/knife/configure.rb +4 -0
- data/lib/chef/knife/cookbook_upload.rb +4 -1
- data/lib/chef/knife/help.rb +98 -0
- data/lib/chef/rest.rb +1 -0
- data/lib/chef/version.rb +1 -1
- metadata +58 -11
- data/distro/common/man/man1/chef-indexer.1 +0 -42
- data/distro/common/man/man1/chef-solr-indexer.1 +0 -55
- data/distro/common/man/man8/chef-solr-rebuild.8 +0 -37
- data/distro/common/man/man8/knife.8 +0 -1349
- data/distro/common/markdown/knife.mkd +0 -865
@@ -0,0 +1,261 @@
|
|
1
|
+
knife(1) -- Chef Server REST API utility
|
2
|
+
========================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
|
6
|
+
__knife__ _sub-command_ _(options)_
|
7
|
+
|
8
|
+
## DESCRIPTION
|
9
|
+
|
10
|
+
This manual page documents knife, a command-line utility used to
|
11
|
+
interact with a Chef server directly through the RESTful API. Knife uses
|
12
|
+
sub-commands to take various actions on different types of Chef objects.
|
13
|
+
Some sub-commands take additional options. General options follow
|
14
|
+
sub-commands and their options. A configuration file can be created for
|
15
|
+
common defaults.
|
16
|
+
|
17
|
+
Unless otherwise specified, output is in JSON format, and input files
|
18
|
+
are also JSON format.
|
19
|
+
|
20
|
+
The Chef class `Chef::Config` that configures the behavior of how knife
|
21
|
+
runs has options that correspond to command-line options. These are
|
22
|
+
noted as `Chef::Config` values.
|
23
|
+
|
24
|
+
## GENERAL OPTIONS
|
25
|
+
|
26
|
+
* `-s`, `--server-url` URL:
|
27
|
+
Chef Server URL, corresponds to `Chef::Config` `chef_server_url`.
|
28
|
+
* `-k`, `--key` KEY:
|
29
|
+
API Client Key, corresponds to `Chef::Config` `client_key`.
|
30
|
+
* `-c`, `--config` CONFIG:
|
31
|
+
The configuration file to use
|
32
|
+
* `-e`, `--editor` EDITOR:
|
33
|
+
Set the editor to use for interactive commands
|
34
|
+
* `-F`, `--format` FORMAT:
|
35
|
+
Which format to use for output
|
36
|
+
* `-l`, `--log_level` LEVEL:
|
37
|
+
Set the log level (debug, info, warn, error, fatal), corresponds to `Chef::Config` `log_level`.
|
38
|
+
* `-L`, `--logfile` LOGLOCATION:
|
39
|
+
Set the log file location, defaults to STDOUT, corresponds to `Chef::Config` `log_location`.
|
40
|
+
* `-n`, `--no-editor`:
|
41
|
+
Do not open EDITOR, just accept the data as is
|
42
|
+
* `-u`, `--user` USER:
|
43
|
+
API Client Username, corresponds to `Chef::Config` `node_name`.
|
44
|
+
* `-p`, `--print-after`:
|
45
|
+
Show the data after a destructive operation
|
46
|
+
* `-v`, `--version`:
|
47
|
+
Show chef version
|
48
|
+
* `-y`, `--yes`:
|
49
|
+
Say yes to all prompts for confirmation
|
50
|
+
* `-h`, `--help`:
|
51
|
+
Show this message
|
52
|
+
|
53
|
+
Usage information for sub-commands can be displayed with `knife SUB-COMMAND --help`.
|
54
|
+
|
55
|
+
## SUB-COMMANDS
|
56
|
+
|
57
|
+
Knife sub-commands are structured as _NOUN verb NOUN (options)_. The
|
58
|
+
sub-commands are meant to be intuitively named. Because the Chef Server
|
59
|
+
API is RESTful, sub-commands generally utilize CRUD operations.
|
60
|
+
|
61
|
+
* create (create)
|
62
|
+
* list and show (read)
|
63
|
+
* edit (update)
|
64
|
+
* delete (destroy)
|
65
|
+
|
66
|
+
Objects stored on the server support these, as described below.
|
67
|
+
|
68
|
+
## GENERAL SUB-COMMANDS
|
69
|
+
|
70
|
+
__recipe list [PATTERN]__
|
71
|
+
|
72
|
+
List available recipes from the server. Specify _PATTERN_ as a regular expression to limit the results.
|
73
|
+
|
74
|
+
|
75
|
+
## CONFIGURATION
|
76
|
+
|
77
|
+
The knife configuration file is a Ruby DSL to set configuration
|
78
|
+
parameters for Knife's __GENERAL OPTIONS__. The default location for the
|
79
|
+
config file is `~/.chef/knife.rb`. If managing multiple Chef
|
80
|
+
repositories, per-repository config files can be created. The file must
|
81
|
+
be `.chef/knife.rb` in the current directory of the repository.
|
82
|
+
|
83
|
+
If the config file exists, knife uses these settings for __GENERAL OPTIONS__ defaults.
|
84
|
+
|
85
|
+
`log_level`
|
86
|
+
|
87
|
+
A Ruby symbol specifying the log level. Corresponds to `-l` or `--log_level` option. Default is _:info_. Valid values are:
|
88
|
+
|
89
|
+
* :info
|
90
|
+
* :debug
|
91
|
+
* :warn
|
92
|
+
* :fatal
|
93
|
+
|
94
|
+
`log_location`
|
95
|
+
|
96
|
+
Corresponds to the `-L` or `--log-file` option. Defaults is __STDOUT__.
|
97
|
+
Valid values are __STDOUT__ or a filename.
|
98
|
+
|
99
|
+
`node_name`
|
100
|
+
|
101
|
+
User to authenticate to the Chef server. Corresponds to the `-u` or
|
102
|
+
`--user` option. This is requested from the user when running this
|
103
|
+
sub-command.
|
104
|
+
|
105
|
+
`client_key`
|
106
|
+
|
107
|
+
Private key file to authenticate to the Chef server. Corresponds to the
|
108
|
+
`-k` or `--key` option. This is requested from the user when running
|
109
|
+
this sub-command.
|
110
|
+
|
111
|
+
`chef_server_url`
|
112
|
+
|
113
|
+
URL of the Chef server. Corresponds to the `-s` or `--server-url`
|
114
|
+
option. This is requested from the user when running this sub-command.
|
115
|
+
|
116
|
+
`cache_type`
|
117
|
+
|
118
|
+
The type of cache to use. Default is BasicFile. This can be any type of
|
119
|
+
Cache that moneta supports: BasicFile, Berkeley, Couch, DataMapper,
|
120
|
+
File, LMC, Memcache, Memory, MongoDB, Redis, Rufus, S3, SDBM, Tyrant,
|
121
|
+
Xattr, YAML.
|
122
|
+
|
123
|
+
`cache_options`
|
124
|
+
|
125
|
+
Specifies various options to use for caching. Default reads the Chef
|
126
|
+
client configuration (/etc/chef/checksums).
|
127
|
+
|
128
|
+
`validation_client_name`
|
129
|
+
|
130
|
+
Specifies the name of the client used to validate new clients. This is
|
131
|
+
requested from the user when running the configuration sub-command.
|
132
|
+
|
133
|
+
`validation_key`
|
134
|
+
|
135
|
+
Specifies the private key file to use for generating ec2 instance data
|
136
|
+
for validating new clients. This is implied from the
|
137
|
+
`validation_client_name`.
|
138
|
+
|
139
|
+
`cookbook_copyright`
|
140
|
+
`cookbook_email`
|
141
|
+
`cookbook_license`
|
142
|
+
|
143
|
+
Used by `knife cookbook create` sub-command to specify the copyright
|
144
|
+
holder, maintainer email and license (respectively) for new cookbooks.
|
145
|
+
The copyright holder is listed as the maintainer in the cookbook's
|
146
|
+
metadata and as the Copyright in the comments of the default recipe. The
|
147
|
+
maintainer email is used in the cookbook metadata. The license
|
148
|
+
determines what preamble to put in the comment of the default recipe,
|
149
|
+
and is listed as the license in the cookbook metadata. Currently
|
150
|
+
supported licenses are "apachev2" and "none". Any other values will
|
151
|
+
result in an empty license in the metadata (needs to be filled in by the
|
152
|
+
author), and no comment preamble in the default recipe.
|
153
|
+
|
154
|
+
`knife[:aws_access_key_id]`
|
155
|
+
`knife[:aws_secret_access_key]`
|
156
|
+
|
157
|
+
Specifies the Amazon AWS EC2 credentials to use when running the ec2 sub-commands.
|
158
|
+
|
159
|
+
`knife[:rackspace_api_username]`
|
160
|
+
`knife[:rackspace_api_key]`
|
161
|
+
|
162
|
+
Specifies the Rackspace Cloud credentials to use when running the rackspace sub-commands.
|
163
|
+
|
164
|
+
`knife[:terremark_username]`
|
165
|
+
`knife[:terremark_password]`
|
166
|
+
`knife[:terremark_service]`
|
167
|
+
|
168
|
+
Specifies the Terremark vCloud credentials to use when running the terremark sub-commands.
|
169
|
+
|
170
|
+
`knife[:slicehost_password]`
|
171
|
+
|
172
|
+
Specifies the Slicehost password to use when running the slicdehost sub-commands.
|
173
|
+
|
174
|
+
## FILES
|
175
|
+
|
176
|
+
_~/.chef/knife.rb_
|
177
|
+
|
178
|
+
Ruby DSL configuration file for knife. See __CONFIGURATION__.
|
179
|
+
|
180
|
+
## CHEF WORKFLOW
|
181
|
+
|
182
|
+
When working with Chef and Knife in the local repository, the recommended workflow outline looks like:
|
183
|
+
|
184
|
+
* Create repository. A skeleton sample is provided at _http://github.com/opscode/chef-repo/_.
|
185
|
+
* Configure knife, see __CONFIGURATION__.
|
186
|
+
* Download cookbooks from the Opscode cookbooks site, see __COOKBOOK SITE SUB-COMMANDS__.
|
187
|
+
* Or, create new cookbooks, see `cookbook create` sub-command.
|
188
|
+
* Commit changes to the version control system. See your tool's documentation.
|
189
|
+
* Upload cookbooks to the Chef Server, see __COOKBOOK SUB-COMMANDS__.
|
190
|
+
* Launch instances in the Cloud, OR provision new hosts; see __CLOUD COMPUTING SUB-COMMANDS__ and __BOOTSTRAP SUB-COMMANDS__.
|
191
|
+
* Watch Chef configure systems!
|
192
|
+
|
193
|
+
A note about git: Opscode and many folks in the Chef community use git,
|
194
|
+
but it is not required, except in the case of the `cookbook site vendor`
|
195
|
+
sub-command, as it uses git directly. Version control is strongly
|
196
|
+
recommended though, and git fits with a lot of the workflow paradigms.
|
197
|
+
|
198
|
+
## EXAMPLES
|
199
|
+
|
200
|
+
Example client config (`/etc/chef/client.rb`) from `knife configure
|
201
|
+
client`. The same configuration is used when using the `knife bootstrap`
|
202
|
+
command with the default `gem` templates that come with Chef.
|
203
|
+
|
204
|
+
log_level :info
|
205
|
+
log_location STDOUT
|
206
|
+
chef_server_url 'https://api.opscode.com/organizations/ORGNAME'
|
207
|
+
validation_client_name 'ORGNAME-validator'
|
208
|
+
|
209
|
+
Setting up a custom bootstrap is fairly straightforward. Create
|
210
|
+
`.chef/bootstrap` in your Chef Repository directory or in
|
211
|
+
`$HOME/.chef/bootstrap`. Then create the ERB template file.
|
212
|
+
|
213
|
+
mkdir ~/.chef/bootstrap
|
214
|
+
vi ~/.chef/bootstrap/debian5.0-apt.erb
|
215
|
+
|
216
|
+
For example, to create a new bootstrap template that should be used when
|
217
|
+
setting up a new Debian node. Edit the template to run the commands, set
|
218
|
+
up the validation certificate and the client configuration file, and
|
219
|
+
finally to run chef-client on completion. The bootstrap template can be
|
220
|
+
called with:
|
221
|
+
|
222
|
+
knife bootstrap mynode.example.com --template-file ~/.chef/bootstrap/debian5.0-apt.erb
|
223
|
+
|
224
|
+
Or,
|
225
|
+
|
226
|
+
knife bootstrap mynode.example.com --distro debian5.0-apt
|
227
|
+
|
228
|
+
The `--distro` parameter will automatically look in the
|
229
|
+
`~/.chef/bootstrap` directory for a file named `debian5.0-apt.erb`.
|
230
|
+
|
231
|
+
Templates provided by the Chef installation are located in
|
232
|
+
`BASEDIR/lib/chef/knife/bootstrap/*.erb`, where _BASEDIR_ is the
|
233
|
+
location where the package or Gem installed the Chef client libraries.
|
234
|
+
|
235
|
+
Uploading cookbooks to the Opscode cookbooks site using the user/certificate specifically:
|
236
|
+
|
237
|
+
knife cookbook site share example Other -k ~/.chef/USERNAME.pem -u USERNAME
|
238
|
+
|
239
|
+
## ENVIRONMENT
|
240
|
+
* `EDITOR`:
|
241
|
+
The text editor to use for editing data. The --editor option takes
|
242
|
+
precedence over this value, and the --no-editor option supresses
|
243
|
+
data editing entirely.
|
244
|
+
|
245
|
+
## SEE ALSO
|
246
|
+
|
247
|
+
Full documentation for Chef is located on the Chef wiki, http://wiki.opscode.com/display/chef/Home/.
|
248
|
+
|
249
|
+
JSON is JavaScript Object Notation and more information can be found at http://json.org/.
|
250
|
+
|
251
|
+
SOLR is an open source search engine. The Chef Server includes a SOLR installation. More information about SOLR, including the search query syntax, can be found at http://lucene.apache.org/solr/.
|
252
|
+
|
253
|
+
Git is a version control system and documented at http://git-scm.com/.
|
254
|
+
|
255
|
+
This manual page was generated in nroff from Markdown with ronn. Ryan Tomayko wrote ronn and more information can be found at http://rtomayko.github.com/ronn/ronn.5.html.
|
256
|
+
|
257
|
+
## AUTHOR
|
258
|
+
|
259
|
+
Chef was written by Adam Jacob <adam@opscode.com> of Opscode (<http://www.opscode.com>), with contributions from the community. 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.
|
260
|
+
|
261
|
+
On Debian systems, the complete text of the Apache 2.0 License can be found in `/usr/share/common-licenses/Apache-2.0`.
|
@@ -27,22 +27,41 @@ require 'chef/version_constraint'
|
|
27
27
|
|
28
28
|
class Chef
|
29
29
|
class Cookbook
|
30
|
+
|
30
31
|
# == Chef::Cookbook::Metadata
|
31
32
|
# Chef::Cookbook::Metadata provides a convenient DSL for declaring metadata
|
32
33
|
# about Chef Cookbooks.
|
33
34
|
class Metadata
|
34
35
|
|
36
|
+
NAME = 'name'.freeze
|
37
|
+
DESCRIPTION = 'description'.freeze
|
38
|
+
LONG_DESCRIPTION = 'long_description'.freeze
|
39
|
+
MAINTAINER = 'maintainer'.freeze
|
40
|
+
MAINTAINER_EMAIL = 'maintainer_email'.freeze
|
41
|
+
LICENSE = 'license'.freeze
|
42
|
+
PLATFORMS = 'platforms'.freeze
|
43
|
+
DEPENDENCIES = 'dependencies'.freeze
|
44
|
+
RECOMMENDATIONS = 'recommendations'.freeze
|
45
|
+
SUGGESTIONS = 'suggestions'.freeze
|
46
|
+
CONFLICTING = 'conflicting'.freeze
|
47
|
+
PROVIDING = 'providing'.freeze
|
48
|
+
REPLACING = 'replacing'.freeze
|
49
|
+
ATTRIBUTES = 'attributes'.freeze
|
50
|
+
GROUPINGS = 'groupings'.freeze
|
51
|
+
RECIPES = 'recipes'.freeze
|
52
|
+
VERSION = 'version'.freeze
|
53
|
+
|
35
54
|
COMPARISON_FIELDS = [ :name, :description, :long_description, :maintainer,
|
36
55
|
:maintainer_email, :license, :platforms, :dependencies,
|
37
56
|
:recommendations, :suggestions, :conflicting, :providing,
|
38
57
|
:replacing, :attributes, :groupings, :recipes, :version]
|
39
58
|
|
40
|
-
VERSION_CONSTRAINTS = {:depends =>
|
41
|
-
:recommends =>
|
42
|
-
:suggests =>
|
43
|
-
:conflicts =>
|
44
|
-
:provides =>
|
45
|
-
:replaces =>
|
59
|
+
VERSION_CONSTRAINTS = {:depends => DEPENDENCIES,
|
60
|
+
:recommends => RECOMMENDATIONS,
|
61
|
+
:suggests => SUGGESTIONS,
|
62
|
+
:conflicts => CONFLICTING,
|
63
|
+
:provides => PROVIDING,
|
64
|
+
:replaces => REPLACING }
|
46
65
|
|
47
66
|
include Chef::Mixin::CheckHelper
|
48
67
|
include Chef::Mixin::ParamsValidate
|
@@ -402,23 +421,23 @@ class Chef
|
|
402
421
|
|
403
422
|
def to_hash
|
404
423
|
{
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
424
|
+
NAME => self.name,
|
425
|
+
DESCRIPTION => self.description,
|
426
|
+
LONG_DESCRIPTION => self.long_description,
|
427
|
+
MAINTAINER => self.maintainer,
|
428
|
+
MAINTAINER_EMAIL => self.maintainer_email,
|
429
|
+
LICENSE => self.license,
|
430
|
+
PLATFORMS => self.platforms,
|
431
|
+
DEPENDENCIES => self.dependencies,
|
432
|
+
RECOMMENDATIONS => self.recommendations,
|
433
|
+
SUGGESTIONS => self.suggestions,
|
434
|
+
CONFLICTING => self.conflicting,
|
435
|
+
PROVIDING => self.providing,
|
436
|
+
REPLACING => self.replacing,
|
437
|
+
ATTRIBUTES => self.attributes,
|
438
|
+
GROUPINGS => self.groupings,
|
439
|
+
RECIPES => self.recipes,
|
440
|
+
VERSION => self.version
|
422
441
|
}
|
423
442
|
end
|
424
443
|
|
@@ -433,23 +452,23 @@ class Chef
|
|
433
452
|
end
|
434
453
|
|
435
454
|
def from_hash(o)
|
436
|
-
@name = o[
|
437
|
-
@description = o[
|
438
|
-
@long_description = o[
|
439
|
-
@maintainer = o[
|
440
|
-
@maintainer_email = o[
|
441
|
-
@license = o[
|
442
|
-
@platforms = o[
|
443
|
-
@dependencies = handle_deprecated_constraints(o[
|
444
|
-
@recommendations = handle_deprecated_constraints(o[
|
445
|
-
@suggestions = handle_deprecated_constraints(o[
|
446
|
-
@conflicting = handle_deprecated_constraints(o[
|
447
|
-
@providing = o[
|
448
|
-
@replacing = handle_deprecated_constraints(o[
|
449
|
-
@attributes = o[
|
450
|
-
@groupings = o[
|
451
|
-
@recipes = o[
|
452
|
-
@version = o[
|
455
|
+
@name = o[NAME] if o.has_key?(NAME)
|
456
|
+
@description = o[DESCRIPTION] if o.has_key?(DESCRIPTION)
|
457
|
+
@long_description = o[LONG_DESCRIPTION] if o.has_key?(LONG_DESCRIPTION)
|
458
|
+
@maintainer = o[MAINTAINER] if o.has_key?(MAINTAINER)
|
459
|
+
@maintainer_email = o[MAINTAINER_EMAIL] if o.has_key?(MAINTAINER_EMAIL)
|
460
|
+
@license = o[LICENSE] if o.has_key?(LICENSE)
|
461
|
+
@platforms = o[PLATFORMS] if o.has_key?(PLATFORMS)
|
462
|
+
@dependencies = handle_deprecated_constraints(o[DEPENDENCIES]) if o.has_key?(DEPENDENCIES)
|
463
|
+
@recommendations = handle_deprecated_constraints(o[RECOMMENDATIONS]) if o.has_key?(RECOMMENDATIONS)
|
464
|
+
@suggestions = handle_deprecated_constraints(o[SUGGESTIONS]) if o.has_key?(SUGGESTIONS)
|
465
|
+
@conflicting = handle_deprecated_constraints(o[CONFLICTING]) if o.has_key?(CONFLICTING)
|
466
|
+
@providing = o[PROVIDING] if o.has_key?(PROVIDING)
|
467
|
+
@replacing = handle_deprecated_constraints(o[REPLACING]) if o.has_key?(REPLACING)
|
468
|
+
@attributes = o[ATTRIBUTES] if o.has_key?(ATTRIBUTES)
|
469
|
+
@groupings = o[GROUPINGS] if o.has_key?(GROUPINGS)
|
470
|
+
@recipes = o[RECIPES] if o.has_key?(RECIPES)
|
471
|
+
@version = o[VERSION] if o.has_key?(VERSION)
|
453
472
|
self
|
454
473
|
end
|
455
474
|
|
@@ -588,5 +607,22 @@ INVALID
|
|
588
607
|
end
|
589
608
|
|
590
609
|
end
|
610
|
+
|
611
|
+
#== Chef::Cookbook::MinimalMetadata
|
612
|
+
# MinimalMetadata is a duck type of Cookbook::Metadata, used
|
613
|
+
# internally by Chef Server when determining the optimal set of
|
614
|
+
# cookbooks for a node.
|
615
|
+
#
|
616
|
+
# MinimalMetadata objects typically contain only enough information
|
617
|
+
# to solve the cookbook collection for a run list, but not enough to
|
618
|
+
# generate the proper response
|
619
|
+
class MinimalMetadata < Metadata
|
620
|
+
def initialize(name, params)
|
621
|
+
@name = name
|
622
|
+
from_hash(params)
|
623
|
+
end
|
624
|
+
end
|
625
|
+
|
626
|
+
|
591
627
|
end
|
592
628
|
end
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# Author:: Christopher Walters (<cw@opscode.com>)
|
4
4
|
# Author:: Tim Hinderliter (<tim@opscode.com>)
|
5
5
|
# Author:: Seth Falcon (<seth@opscode.com>)
|
6
|
-
#
|
6
|
+
# Author:: Daniel DeLeo (<dan@opscode.com>)
|
7
|
+
# Copyright:: Copyright 2008-2011 Opscode, Inc.
|
7
8
|
# License:: Apache License, Version 2.0
|
8
9
|
#
|
9
10
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -29,6 +30,80 @@ require 'chef/cookbook/metadata'
|
|
29
30
|
require 'chef/version_class'
|
30
31
|
|
31
32
|
class Chef
|
33
|
+
|
34
|
+
#== Chef::MinimalCookbookVersion
|
35
|
+
# MinimalCookbookVersion is a duck type of CookbookVersion, used
|
36
|
+
# internally by Chef Server as an optimization when determining the
|
37
|
+
# optimal cookbook set for a chef-client.
|
38
|
+
#
|
39
|
+
# MinimalCookbookVersion objects contain only enough information to
|
40
|
+
# solve the cookbook collection for a given run list. They *do not*
|
41
|
+
# contain enough information to generate the response.
|
42
|
+
#
|
43
|
+
# See also: Chef::CookbookVersionSelector
|
44
|
+
class MinimalCookbookVersion
|
45
|
+
|
46
|
+
include Comparable
|
47
|
+
|
48
|
+
ID = "id".freeze
|
49
|
+
NAME = 'name'.freeze
|
50
|
+
KEY = 'key'.freeze
|
51
|
+
VERSION = 'version'.freeze
|
52
|
+
VALUE = 'value'.freeze
|
53
|
+
DEPS = 'deps'.freeze
|
54
|
+
|
55
|
+
DEPENDENCIES = 'dependencies'.freeze
|
56
|
+
|
57
|
+
# Loads the full list of cookbooks, using a couchdb view to fetch
|
58
|
+
# only the id, name, version, and dependency constraints. This is
|
59
|
+
# enough information to solve for the cookbook collection for a
|
60
|
+
# given run list. After solving for the cookbook collection, you
|
61
|
+
# need to call +load_full_versions_of+ to convert
|
62
|
+
# MinimalCookbookVersion objects to their non-minimal counterparts
|
63
|
+
def self.load_all(couchdb)
|
64
|
+
# Example:
|
65
|
+
# {"id"=>"1a806f1c-b409-4d8e-abab-fa414ff5b96d", "key"=>"activemq", "value"=>{"version"=>"0.3.3", "deps"=>{"java"=>">= 0.0.0", "runit"=>">= 0.0.0"}}}
|
66
|
+
couchdb ||= Chef::CouchDB.new
|
67
|
+
couchdb.get_view("cookbooks", "all_with_version_and_deps")["rows"].map {|params| self.new(params) }
|
68
|
+
end
|
69
|
+
|
70
|
+
# Loads the non-minimal CookbookVersion objects corresponding to
|
71
|
+
# +minimal_cookbook_versions+ from couchdb using a bulk GET.
|
72
|
+
def self.load_full_versions_of(minimal_cookbook_versions, couchdb)
|
73
|
+
database_ids = Array(minimal_cookbook_versions).map {|mcv| mcv.couchdb_id }
|
74
|
+
couchdb ||= Chef::CouchDB.new
|
75
|
+
couchdb.bulk_get(*database_ids)
|
76
|
+
end
|
77
|
+
|
78
|
+
attr_reader :couchdb_id
|
79
|
+
attr_reader :name
|
80
|
+
attr_reader :version
|
81
|
+
attr_reader :deps
|
82
|
+
|
83
|
+
def initialize(params)
|
84
|
+
@couchdb_id = params[ID]
|
85
|
+
@name = params[KEY]
|
86
|
+
@version = params[VALUE][VERSION]
|
87
|
+
@deps = params[VALUE][DEPS]
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns the Cookbook::MinimalMetadata object for this cookbook
|
91
|
+
# version.
|
92
|
+
def metadata
|
93
|
+
@metadata ||= Cookbook::MinimalMetadata.new(@name, DEPENDENCIES => @deps)
|
94
|
+
end
|
95
|
+
|
96
|
+
def legit_version
|
97
|
+
@legit_version ||= Chef::Version.new(@version)
|
98
|
+
end
|
99
|
+
|
100
|
+
def <=>(o)
|
101
|
+
raise Chef::Exceptions::CookbookVersionNameMismatch if self.name != o.name
|
102
|
+
raise "Unexpected comparison to #{o}" unless o.respond_to?(:legit_version)
|
103
|
+
legit_version <=> o.legit_version
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
32
107
|
# == Chef::CookbookVersion
|
33
108
|
# CookbookVersion is a model object encapsulating the data about a Chef
|
34
109
|
# cookbook. Chef supports maintaining multiple versions of a cookbook on a
|
@@ -44,7 +119,7 @@ class Chef
|
|
44
119
|
COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ]
|
45
120
|
|
46
121
|
DESIGN_DOCUMENT = {
|
47
|
-
"version" =>
|
122
|
+
"version" => 8,
|
48
123
|
"language" => "javascript",
|
49
124
|
"views" => {
|
50
125
|
"all" => {
|
@@ -74,6 +149,15 @@ class Chef
|
|
74
149
|
}
|
75
150
|
EOJS
|
76
151
|
},
|
152
|
+
"all_with_version_and_deps" => {
|
153
|
+
"map" => <<-JS
|
154
|
+
function(doc) {
|
155
|
+
if (doc.chef_type == "cookbook_version") {
|
156
|
+
emit(doc.cookbook_name, {version: doc.version, deps: doc.metadata.dependencies});
|
157
|
+
}
|
158
|
+
}
|
159
|
+
JS
|
160
|
+
},
|
77
161
|
"all_latest_version" => {
|
78
162
|
"map" => %q@
|
79
163
|
function(doc) {
|