chef 0.10.2 → 0.10.4.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/distro/common/html/chef-client.8.html +4 -4
  2. data/distro/common/html/knife-cookbook.1.html +5 -3
  3. data/distro/common/html/knife-node.1.html +4 -4
  4. data/distro/common/man/man1/knife-cookbook.1 +5 -1
  5. data/distro/common/man/man1/knife-node.1 +1 -1
  6. data/distro/common/markdown/man1/knife-cookbook-site.mkd +3 -3
  7. data/distro/common/markdown/man1/knife-cookbook.mkd +7 -0
  8. data/distro/common/markdown/man1/knife-node.mkd +4 -3
  9. data/distro/common/markdown/man1/knife-ssh.mkd +2 -0
  10. data/lib/chef/application.rb +1 -0
  11. data/lib/chef/cookbook_loader.rb +18 -0
  12. data/lib/chef/cookbook_uploader.rb +1 -1
  13. data/lib/chef/data_bag.rb +14 -2
  14. data/lib/chef/data_bag_item.rb +8 -2
  15. data/lib/chef/encrypted_data_bag_item.rb +19 -6
  16. data/lib/chef/environment.rb +12 -6
  17. data/lib/chef/exceptions.rb +1 -0
  18. data/lib/chef/knife.rb +0 -28
  19. data/lib/chef/knife/bootstrap.rb +7 -0
  20. data/lib/chef/knife/bootstrap/archlinux-gems.erb +14 -12
  21. data/lib/chef/knife/bootstrap/centos5-gems.erb +8 -5
  22. data/lib/chef/knife/bootstrap/fedora13-gems.erb +2 -0
  23. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +16 -9
  24. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +6 -3
  25. data/lib/chef/knife/client_bulk_delete.rb +28 -6
  26. data/lib/chef/knife/cookbook_site_install.rb +2 -2
  27. data/lib/chef/knife/cookbook_upload.rb +71 -0
  28. data/lib/chef/knife/core/bootstrap_context.rb +13 -3
  29. data/lib/chef/knife/core/cookbook_scm_repo.rb +2 -3
  30. data/lib/chef/knife/core/node_presenter.rb +5 -2
  31. data/lib/chef/knife/help.rb +13 -12
  32. data/lib/chef/knife/help_topics.rb +4 -0
  33. data/lib/chef/knife/ssh.rb +25 -4
  34. data/lib/chef/mixin/create_path.rb +3 -2
  35. data/lib/chef/mixin/get_source_from_package.rb +42 -0
  36. data/lib/chef/mixin/language.rb +8 -11
  37. data/lib/chef/monkey_patches/numeric.rb +9 -1
  38. data/lib/chef/monkey_patches/string.rb +21 -0
  39. data/lib/chef/platform.rb +2 -1
  40. data/lib/chef/provider.rb +1 -1
  41. data/lib/chef/provider/git.rb +16 -3
  42. data/lib/chef/provider/group/suse.rb +53 -0
  43. data/lib/chef/provider/mount/mount.rb +28 -20
  44. data/lib/chef/provider/package/apt.rb +39 -24
  45. data/lib/chef/provider/package/dpkg.rb +5 -2
  46. data/lib/chef/provider/package/easy_install.rb +2 -2
  47. data/lib/chef/provider/package/freebsd.rb +5 -2
  48. data/lib/chef/provider/package/macports.rb +4 -4
  49. data/lib/chef/provider/package/rpm.rb +4 -1
  50. data/lib/chef/provider/package/rubygems.rb +3 -0
  51. data/lib/chef/provider/package/solaris.rb +3 -0
  52. data/lib/chef/provider/package/yum-dump.py +239 -81
  53. data/lib/chef/provider/package/yum.rb +977 -110
  54. data/lib/chef/provider/package/zypper.rb +20 -3
  55. data/lib/chef/provider/remote_directory.rb +0 -1
  56. data/lib/chef/provider/service/arch.rb +35 -28
  57. data/lib/chef/provider/service/systemd.rb +102 -0
  58. data/lib/chef/provider/service/upstart.rb +8 -2
  59. data/lib/chef/providers.rb +2 -0
  60. data/lib/chef/resource.rb +31 -2
  61. data/lib/chef/resource/git.rb +9 -0
  62. data/lib/chef/resource/mount.rb +1 -2
  63. data/lib/chef/resource/yum_package.rb +20 -0
  64. data/lib/chef/rest.rb +1 -1
  65. data/lib/chef/role.rb +1 -1
  66. data/lib/chef/run_context.rb +3 -3
  67. data/lib/chef/runner.rb +15 -2
  68. data/lib/chef/shell_out.rb +1 -1
  69. data/lib/chef/shell_out/windows.rb +2 -2
  70. data/lib/chef/solr_query.rb +1 -1
  71. data/lib/chef/tasks/chef_repo.rake +1 -1
  72. data/lib/chef/version.rb +1 -1
  73. metadata +425 -441
@@ -120,9 +120,9 @@ wiki, http://wiki.opscode.com/display/chef/Home.</p>
120
120
 
121
121
  <h2 id="AUTHOR">AUTHOR</h2>
122
122
 
123
- <p>Chef was written by Adam Jacob <a href="&#x6d;&#97;&#105;&#x6c;&#116;&#111;&#58;&#x61;&#100;&#97;&#109;&#64;&#x6f;&#115;&#112;&#99;&#111;&#100;&#101;&#46;&#99;&#111;&#109;" data-bare-link="true">&#x61;&#x64;&#97;&#109;&#x40;&#111;&#x73;&#112;&#99;&#x6f;&#100;&#x65;&#46;&#x63;&#x6f;&#x6d;</a> of Opscode
123
+ <p>Chef was written by Adam Jacob <a href="&#x6d;&#97;&#105;&#x6c;&#116;&#x6f;&#58;&#97;&#100;&#x61;&#x6d;&#x40;&#111;&#x73;&#x70;&#99;&#111;&#100;&#101;&#46;&#x63;&#111;&#x6d;" data-bare-link="true">&#x61;&#x64;&#97;&#109;&#64;&#111;&#115;&#112;&#x63;&#111;&#x64;&#101;&#46;&#99;&#111;&#109;</a> of Opscode
124
124
  (http://www.opscode.com), with contributions from the community. This
125
- manual page was written by Joshua Timberman <a href="&#x6d;&#x61;&#105;&#108;&#x74;&#111;&#58;&#x6a;&#111;&#115;&#x68;&#117;&#x61;&#x40;&#111;&#112;&#115;&#99;&#111;&#x64;&#x65;&#x2e;&#x63;&#x6f;&#x6d;" data-bare-link="true">&#106;&#111;&#x73;&#x68;&#x75;&#97;&#64;&#111;&#112;&#115;&#x63;&#x6f;&#100;&#101;&#x2e;&#x63;&#x6f;&#109;</a> with
125
+ manual page was written by Joshua Timberman <a href="&#109;&#x61;&#x69;&#x6c;&#116;&#x6f;&#58;&#106;&#x6f;&#115;&#104;&#x75;&#x61;&#64;&#111;&#112;&#x73;&#99;&#111;&#x64;&#101;&#46;&#x63;&#111;&#109;" data-bare-link="true">&#106;&#111;&#115;&#104;&#x75;&#x61;&#64;&#111;&#112;&#x73;&#99;&#x6f;&#x64;&#101;&#46;&#x63;&#111;&#109;</a> with
126
126
  help2man. Permission is granted to copy, distribute and / or modify
127
127
  this document under the terms of the Apache 2.0 License.</p>
128
128
 
@@ -131,8 +131,8 @@ found in /usr/share/common-licenses/Apache-2.0.</p>
131
131
 
132
132
 
133
133
  <ol class='man-decor man-foot man foot'>
134
- <li class='tl'>Chef 0.10.2</li>
135
- <li class='tc'>June 2011</li>
134
+ <li class='tl'>Chef 0.10.0</li>
135
+ <li class='tc'>April 2011</li>
136
136
  <li class='tr'>chef-client(8)</li>
137
137
  </ol>
138
138
 
@@ -143,6 +143,8 @@
143
143
  <dl>
144
144
  <dt><code>-a</code>, <code>--all</code></dt><dd>upload all cookbooks, rather than just a single cookbook</dd>
145
145
  <dt><code>-o</code>, <code>--cookbook-path path:path</code></dt><dd>a colon-separated path to look for cookbooks in</dd>
146
+ <dt><code>-d</code>, <code>--upload-dependencies</code></dt><dd>Uploads additional cookbooks that this cookbook lists in as
147
+ dependencies in its metadata.</dd>
146
148
  <dt><code>-E</code>, <code>--environment ENVIRONMENT</code></dt><dd>An <em>ENVIRONMENT</em> to apply the uploaded cookbooks to. Specifying this
147
149
  option will cause knife to edit the <em>ENVIRONMENT</em> to place a strict
148
150
  version constraint on the cookbook version(s) uploaded.</dd>
@@ -350,11 +352,11 @@ cookbook.</p>
350
352
 
351
353
  <h2 id="AUTHOR">AUTHOR</h2>
352
354
 
353
- <p> Chef was written by Adam Jacob <a href="&#x6d;&#x61;&#105;&#108;&#x74;&#111;&#58;&#x61;&#100;&#97;&#109;&#x40;&#111;&#x70;&#x73;&#x63;&#x6f;&#100;&#101;&#x2e;&#99;&#111;&#x6d;" data-bare-link="true">&#97;&#100;&#97;&#x6d;&#x40;&#111;&#112;&#x73;&#x63;&#x6f;&#x64;&#101;&#46;&#x63;&#111;&#109;</a> with many contributions from the community.</p>
355
+ <p> Chef was written by Adam Jacob <a href="&#x6d;&#97;&#x69;&#x6c;&#116;&#x6f;&#x3a;&#97;&#x64;&#97;&#x6d;&#64;&#111;&#x70;&#115;&#99;&#x6f;&#x64;&#101;&#46;&#99;&#111;&#109;" data-bare-link="true">&#x61;&#x64;&#x61;&#109;&#64;&#111;&#x70;&#115;&#x63;&#x6f;&#100;&#101;&#x2e;&#x63;&#x6f;&#x6d;</a> with many contributions from the community.</p>
354
356
 
355
357
  <h2 id="DOCUMENTATION">DOCUMENTATION</h2>
356
358
 
357
- <p> This manual page was written by Joshua Timberman <a href="&#x6d;&#97;&#105;&#108;&#116;&#x6f;&#58;&#106;&#111;&#115;&#104;&#x75;&#97;&#64;&#x6f;&#x70;&#x73;&#x63;&#111;&#100;&#x65;&#46;&#x63;&#111;&#x6d;" data-bare-link="true">&#106;&#111;&#x73;&#x68;&#x75;&#x61;&#64;&#x6f;&#112;&#115;&#99;&#x6f;&#100;&#101;&#46;&#x63;&#111;&#x6d;</a>.
359
+ <p> This manual page was written by Joshua Timberman <a href="&#109;&#x61;&#105;&#108;&#116;&#111;&#x3a;&#106;&#x6f;&#115;&#104;&#x75;&#x61;&#x40;&#x6f;&#112;&#115;&#x63;&#111;&#x64;&#x65;&#46;&#x63;&#111;&#x6d;" data-bare-link="true">&#x6a;&#111;&#x73;&#104;&#117;&#97;&#x40;&#x6f;&#x70;&#x73;&#x63;&#x6f;&#100;&#x65;&#46;&#x63;&#111;&#x6d;</a>.
358
360
  Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.</p>
359
361
 
360
362
  <h2 id="CHEF">CHEF</h2>
@@ -364,7 +366,7 @@ cookbook.</p>
364
366
 
365
367
  <ol class='man-decor man-foot man foot'>
366
368
  <li class='tl'>Chef 0.10.0</li>
367
- <li class='tc'>April 2011</li>
369
+ <li class='tc'>May 2011</li>
368
370
  <li class='tr'>knife-cookbook(1)</li>
369
371
  </ol>
370
372
 
@@ -247,11 +247,11 @@ run list, the correct syntax is "role[ROLE_NAME]"</p>
247
247
 
248
248
  <h2 id="AUTHOR">AUTHOR</h2>
249
249
 
250
- <p> Chef was written by Adam Jacob <a href="&#x6d;&#97;&#105;&#x6c;&#116;&#111;&#58;&#x61;&#100;&#97;&#109;&#64;&#x6f;&#112;&#115;&#99;&#111;&#100;&#101;&#46;&#99;&#111;&#109;" data-bare-link="true">&#x61;&#x64;&#97;&#109;&#x40;&#111;&#x70;&#115;&#99;&#x6f;&#100;&#x65;&#46;&#x63;&#x6f;&#x6d;</a> with many contributions from the community.</p>
250
+ <p> Chef was written by Adam Jacob <a href="&#x6d;&#97;&#105;&#x6c;&#x74;&#x6f;&#x3a;&#x61;&#100;&#x61;&#109;&#x40;&#x6f;&#112;&#115;&#x63;&#x6f;&#100;&#101;&#x2e;&#x63;&#x6f;&#x6d;" data-bare-link="true">&#x61;&#x64;&#x61;&#x6d;&#x40;&#111;&#112;&#115;&#99;&#111;&#100;&#x65;&#x2e;&#x63;&#111;&#x6d;</a> with many contributions from the community.</p>
251
251
 
252
252
  <h2 id="DOCUMENTATION">DOCUMENTATION</h2>
253
253
 
254
- <p> This manual page was written by Joshua Timberman <a href="&#x6d;&#x61;&#105;&#108;&#x74;&#111;&#58;&#x6a;&#111;&#115;&#x68;&#117;&#x61;&#x40;&#111;&#112;&#115;&#99;&#111;&#x64;&#x65;&#x2e;&#x63;&#x6f;&#x6d;" data-bare-link="true">&#106;&#111;&#x73;&#x68;&#x75;&#97;&#64;&#111;&#112;&#115;&#x63;&#x6f;&#100;&#101;&#x2e;&#x63;&#x6f;&#109;</a>.
254
+ <p> This manual page was written by Joshua Timberman <a href="&#109;&#x61;&#x69;&#x6c;&#x74;&#x6f;&#x3a;&#106;&#x6f;&#x73;&#104;&#117;&#x61;&#x40;&#x6f;&#112;&#x73;&#99;&#x6f;&#100;&#x65;&#x2e;&#99;&#x6f;&#109;" data-bare-link="true">&#106;&#111;&#x73;&#x68;&#x75;&#97;&#x40;&#111;&#x70;&#115;&#x63;&#x6f;&#100;&#x65;&#46;&#x63;&#111;&#109;</a>.
255
255
  Permission is granted to copy, distribute and / or modify this document under the terms of the Apache 2.0 License.</p>
256
256
 
257
257
  <h2 id="CHEF">CHEF</h2>
@@ -260,8 +260,8 @@ run list, the correct syntax is "role[ROLE_NAME]"</p>
260
260
 
261
261
 
262
262
  <ol class='man-decor man-foot man foot'>
263
- <li class='tl'>Chef 0.10.2</li>
264
- <li class='tc'>June 2011</li>
263
+ <li class='tl'>Chef 0.10.0</li>
264
+ <li class='tc'>April 2011</li>
265
265
  <li class='tr'>knife-node(1)</li>
266
266
  </ol>
267
267
 
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-COOKBOOK" "1" "April 2011" "Chef 0.10.0" "Chef Manual"
4
+ .TH "KNIFE\-COOKBOOK" "1" "May 2011" "Chef 0.10.0" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-cookbook\fR \- upload and manage chef cookbooks
@@ -82,6 +82,10 @@ upload all cookbooks, rather than just a single cookbook
82
82
  a colon\-separated path to look for cookbooks in
83
83
  .
84
84
  .TP
85
+ \fB\-d\fR, \fB\-\-upload\-dependencies\fR
86
+ Uploads additional cookbooks that this cookbook lists in as dependencies in its metadata\.
87
+ .
88
+ .TP
85
89
  \fB\-E\fR, \fB\-\-environment ENVIRONMENT\fR
86
90
  An \fIENVIRONMENT\fR to apply the uploaded cookbooks to\. Specifying this option will cause knife to edit the \fIENVIRONMENT\fR to place a strict version constraint on the cookbook version(s) uploaded\.
87
91
  .
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KNIFE\-NODE" "1" "June 2011" "Chef 0.10.2" "Chef Manual"
4
+ .TH "KNIFE\-NODE" "1" "April 2011" "Chef 0.10.0" "Chef Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBknife\-node\fR \- Manage the hosts in your infrastructure
@@ -11,8 +11,8 @@ __knife__ __cookbook site__ _sub-command_ _(options)_
11
11
  ## INSTALL
12
12
  __cookbook site install COOKBOOK [VERSION]__ _(options)_
13
13
 
14
- * `-d`, `--dependencies`:
15
- Grab dependencies automatically
14
+ * `-D`, `--no-dependencies `:
15
+ Do not install dependencies automatically
16
16
 
17
17
  Uses git(1) version control in conjunction with the cookbook site to
18
18
  install community contributed cookbooks to your local cookbook
@@ -31,7 +31,7 @@ changes as a separate patch. When an updated upstream version becomes
31
31
  available, you will be able to merge the upstream changes while
32
32
  maintaining your local modifications.
33
33
 
34
- If _-d_ is specified, the process is applied recursively to all the
34
+ Unless _-D_ is specified, the process is applied recursively to all the
35
35
  cookbooks _COOKBOOK_ depends on (via metadata _dependencies_).
36
36
 
37
37
  ## DOWNLOAD
@@ -46,6 +46,9 @@ __knife cookbook upload [cookbooks...]__ _(options)_
46
46
  upload all cookbooks, rather than just a single cookbook
47
47
  * `-o`, `--cookbook-path path:path`:
48
48
  a colon-separated path to look for cookbooks in
49
+ * `-d`, `--upload-dependencies`:
50
+ Uploads additional cookbooks that this cookbook lists in as
51
+ dependencies in its metadata.
49
52
  * `-E`, `--environment ENVIRONMENT`:
50
53
  An _ENVIRONMENT_ to apply the uploaded cookbooks to. Specifying this
51
54
  option will cause knife to edit the _ENVIRONMENT_ to place a strict
@@ -63,6 +66,10 @@ Uploads one or more cookbooks from your local cookbook repository(ies)
63
66
  to the Chef Server. Only files that don't yet exist on the server will
64
67
  be uploaded.
65
68
 
69
+ As the command parses the name args as 1..n cookbook names:
70
+ `knife cookbook upload COOKBOOK COOKBOOK ...`
71
+ works for one to many cookbooks.
72
+
66
73
  ## DOWNLOAD
67
74
  __knife cookbook download cookbook [version]__ _(options)_
68
75
 
@@ -102,13 +102,14 @@ __knife node show__ _node name_ _(options)_
102
102
 
103
103
  Displays the node identified by _node name_ on stdout. The amount of
104
104
  content displayed and the output format are modified by the --format
105
- option. Valid formats are:
105
+ option. If no alternate format is selected, the default is summary.
106
+ Valid formats are:
106
107
 
107
108
  * summary:
108
- displays the node in a custom, summarized format
109
+ displays the node in a custom, summarized format (default)
109
110
  * text
110
111
  displays the node data in its entirety using the colorized tree
111
- display
112
+ display
112
113
  * json:
113
114
  displays the node in JSON format
114
115
  * yaml:
@@ -15,6 +15,8 @@ __knife__ __ssh QUERY COMMAND__ _(options)_
15
15
  The ssh password
16
16
  * `-x`, `--ssh-user USERNAME `:
17
17
  The ssh username
18
+ * `-i`, `--identity-file IDENTITY_FILE`:
19
+ The SSH identity file used for authentication
18
20
 
19
21
  ## DESCRIPTION
20
22
 
@@ -15,6 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
+ require 'socket'
18
19
  require 'chef/config'
19
20
  require 'chef/exceptions'
20
21
  require 'chef/log'
@@ -30,6 +30,8 @@ class Chef
30
30
 
31
31
  attr_accessor :metadata
32
32
  attr_reader :cookbooks_by_name
33
+ attr_reader :merged_cookbooks
34
+ attr_reader :cookbook_paths
33
35
 
34
36
  include Enumerable
35
37
 
@@ -39,9 +41,23 @@ class Chef
39
41
  @cookbooks_by_name = Mash.new
40
42
  @loaded_cookbooks = {}
41
43
  @metadata = Mash.new
44
+ @cookbooks_paths = Hash.new {|h,k| h[k] = []} # for deprecation warnings
45
+
46
+ # Used to track which cookbooks appear in multiple places in the cookbook repos
47
+ # and are merged in to a single cookbook by file shadowing. This behavior is
48
+ # deprecated, so users of this class may issue warnings to the user by checking
49
+ # this variable
50
+ @merged_cookbooks = []
51
+
42
52
  load_cookbooks
43
53
  end
44
54
 
55
+ def merged_cookbook_paths # for deprecation warnings
56
+ merged_cookbook_paths = {}
57
+ @merged_cookbooks.each {|c| merged_cookbook_paths[c] = @cookbooks_paths[c]}
58
+ merged_cookbook_paths
59
+ end
60
+
45
61
  def load_cookbooks
46
62
  cookbook_settings = Hash.new
47
63
  @repo_paths.each do |repo_path|
@@ -52,7 +68,9 @@ class Chef
52
68
  loader = Cookbook::CookbookVersionLoader.new(cookbook_path, chefignore)
53
69
  loader.load_cookbooks
54
70
  next if loader.empty?
71
+ @cookbooks_paths[loader.cookbook_name] << cookbook_path # for deprecation warnings
55
72
  if @loaded_cookbooks.key?(loader.cookbook_name)
73
+ @merged_cookbooks << loader.cookbook_name # for deprecation warnings
56
74
  @loaded_cookbooks[loader.cookbook_name].merge!(loader)
57
75
  else
58
76
  @loaded_cookbooks[loader.cookbook_name] = loader
@@ -134,7 +134,7 @@ class Chef
134
134
  RestClient::Resource.new(url, :headers=>headers, :timeout=>1800, :open_timeout=>1800).put(file_contents)
135
135
  checksums_to_upload.delete(checksum)
136
136
  rescue RestClient::Exception => e
137
- ui.error("Failed to upload #@cookbook : #{e.message}\n#{e.response.body}")
137
+ Chef::Knife.ui.error("Failed to upload #@cookbook : #{e.message}\n#{e.response.body}")
138
138
  raise
139
139
  end
140
140
  end
@@ -152,9 +152,21 @@ class Chef
152
152
  (couchdb || Chef::CouchDB.new).load("data_bag", name)
153
153
  end
154
154
 
155
- # Load a Data Bag by name via the RESTful API
155
+ # Load a Data Bag by name via either the RESTful API or local data_bag_path if run in solo mode
156
156
  def self.load(name)
157
- Chef::REST.new(Chef::Config[:chef_server_url]).get_rest("data/#{name}")
157
+ if Chef::Config[:solo]
158
+ unless File.directory?(Chef::Config[:data_bag_path])
159
+ raise Chef::Exceptions::InvalidDataBagPath, "Data bag path '#{Chef::Config[:data_bag_path]}' is invalid"
160
+ end
161
+
162
+ Dir.glob(File.join(Chef::Config[:data_bag_path], name, "*.json")).inject({}) do |bag, f|
163
+ item = JSON.parse(IO.read(f))
164
+ bag[item['id']] = item
165
+ bag
166
+ end
167
+ else
168
+ Chef::REST.new(Chef::Config[:chef_server_url]).get_rest("data/#{name}")
169
+ end
158
170
  end
159
171
 
160
172
  # Remove this Data Bag from CouchDB
@@ -187,9 +187,15 @@ class Chef
187
187
  (couchdb || Chef::CouchDB.new).load("data_bag_item", object_name(data_bag, name))
188
188
  end
189
189
 
190
- # Load a Data Bag Item by name via RESTful API
190
+ # Load a Data Bag Item by name via either the RESTful API or local data_bag_path if run in solo mode
191
191
  def self.load(data_bag, name)
192
- item = Chef::REST.new(Chef::Config[:chef_server_url]).get_rest("data/#{data_bag}/#{name}")
192
+ if Chef::Config[:solo]
193
+ bag = Chef::DataBag.load(data_bag)
194
+ item = bag[name]
195
+ else
196
+ item = Chef::REST.new(Chef::Config[:chef_server_url]).get_rest("data/#{data_bag}/#{name}")
197
+ end
198
+
193
199
  if item.kind_of?(DataBagItem)
194
200
  item
195
201
  else
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Seth Falcon (<seth@opscode.com>)
3
- # Copyright:: Copyright 2010 Opscode, Inc.
3
+ # Copyright:: Copyright 2010-2011 Opscode, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +20,7 @@ require 'base64'
20
20
  require 'openssl'
21
21
  require 'chef/data_bag_item'
22
22
  require 'yaml'
23
+ require 'open-uri'
23
24
 
24
25
  # An EncryptedDataBagItem represents a read-only data bag item where
25
26
  # all values, except for the value associated with the id key, have
@@ -56,7 +57,7 @@ class Chef::EncryptedDataBagItem
56
57
 
57
58
  def [](key)
58
59
  value = @enc_hash[key]
59
- if key == "id"
60
+ if key == "id" || value.nil?
60
61
  value
61
62
  else
62
63
  self.class.decrypt_value(value, @secret)
@@ -103,10 +104,22 @@ class Chef::EncryptedDataBagItem
103
104
 
104
105
  def self.load_secret(path=nil)
105
106
  path = path || Chef::Config[:encrypted_data_bag_secret] || DEFAULT_SECRET_FILE
106
- if !File.exists?(path)
107
- raise Errno::ENOENT, "file not found '#{path}'"
108
- end
109
- secret = IO.read(path).strip
107
+ secret = case path
108
+ when /^\w+:\/\//
109
+ # We have a remote key
110
+ begin
111
+ Kernel.open(path).read.strip
112
+ rescue Errno::ECONNREFUSED
113
+ raise ArgumentError, "Remote key not available from '#{path}'"
114
+ rescue OpenURI::HTTPError
115
+ raise ArgumentError, "Remote key not found at '#{path}'"
116
+ end
117
+ else
118
+ if !File.exists?(path)
119
+ raise Errno::ENOENT, "file not found '#{path}'"
120
+ end
121
+ IO.read(path).strip
122
+ end
110
123
  if secret.size < 1
111
124
  raise ArgumentError, "invalid zero length secret in '#{path}'"
112
125
  end
@@ -1,6 +1,7 @@
1
1
  #
2
2
  # Author:: Stephen Delano (<stephen@opscode.com>)
3
3
  # Author:: Seth Falcon (<seth@opscode.com>)
4
+ # Author:: John Keiser (<jkeiser@ospcode.com>)
4
5
  # Copyright:: Copyright 2010-2011 Opscode, Inc.
5
6
  # License:: Apache License, Version 2.0
6
7
  #
@@ -398,12 +399,17 @@ class Chef
398
399
 
399
400
  def self.cdb_load_filtered_recipe_list(name, couchdb=nil)
400
401
  cdb_load_filtered_cookbook_versions(name, couchdb).map do |cb_name, cb|
401
- cb.first.recipe_filenames_by_name.keys.map do |recipe|
402
- case recipe
403
- when DEFAULT
404
- cb_name
405
- else
406
- "#{cb_name}::#{recipe}"
402
+ if cb.empty? # no available versions
403
+ [] # empty list elided with flatten
404
+ else
405
+ latest_version = cb.first
406
+ latest_version.recipe_filenames_by_name.keys.map do |recipe|
407
+ case recipe
408
+ when DEFAULT
409
+ cb_name
410
+ else
411
+ "#{cb_name}::#{recipe}"
412
+ end
407
413
  end
408
414
  end
409
415
  end.flatten
@@ -76,6 +76,7 @@ class Chef
76
76
  class EnclosingDirectoryDoesNotExist < ArgumentError; end
77
77
 
78
78
  class ObsoleteDependencySyntax < ArgumentError; end
79
+ class InvalidDataBagPath < ArgumentError; end
79
80
 
80
81
  # A different version of a cookbook was added to a
81
82
  # VersionedRecipeList than the one already there.
@@ -497,34 +497,6 @@ class Chef
497
497
  self.msg("Deleted #{obj_name}")
498
498
  end
499
499
 
500
- def bulk_delete(klass, fancy_name, delete_name=nil, list=nil, regex=nil, &block)
501
- object_list = list ? list : klass.list(true)
502
-
503
- if regex
504
- to_delete = Hash.new
505
- object_list.each_key do |object|
506
- next if regex && object !~ /#{regex}/
507
- to_delete[object] = object_list[object]
508
- end
509
- else
510
- to_delete = object_list
511
- end
512
-
513
- output(format_list_for_display(to_delete))
514
-
515
- confirm("Do you really want to delete the above items")
516
-
517
- to_delete.each do |name, object|
518
- if Kernel.block_given?
519
- block.call(name, object)
520
- else
521
- object.destroy
522
- end
523
- output(format_for_display(object)) if config[:print_after]
524
- self.msg("Deleted #{fancy_name} #{name}")
525
- end
526
- end
527
-
528
500
  def rest
529
501
  @rest ||= begin
530
502
  require 'chef/rest'
@@ -72,6 +72,11 @@ class Chef
72
72
  :description => "The version of Chef to install",
73
73
  :proc => lambda { |v| Chef::Config[:knife][:bootstrap_version] = v }
74
74
 
75
+ option :bootstrap_proxy,
76
+ :long => "--bootstrap-proxy PROXY_URL",
77
+ :description => "The proxy server for the node being bootstrapped",
78
+ :proc => Proc.new { |p| Chef::Config[:knife][:bootstrap_proxy] = p }
79
+
75
80
  option :distro,
76
81
  :short => "-d DISTRO",
77
82
  :long => "--distro DISTRO",
@@ -110,6 +115,7 @@ class Chef
110
115
  bootstrap_files << File.join(File.dirname(__FILE__), 'bootstrap', "#{config[:distro]}.erb")
111
116
  bootstrap_files << File.join(Dir.pwd, ".chef", "bootstrap", "#{config[:distro]}.erb")
112
117
  bootstrap_files << File.join(ENV['HOME'], '.chef', 'bootstrap', "#{config[:distro]}.erb")
118
+ bootstrap_files << Gem.find_files(File.join("chef","knife","bootstrap","#{config[:distro]}.erb"))
113
119
  end
114
120
 
115
121
  template = Array(bootstrap_files).find do |bootstrap_template|
@@ -166,6 +172,7 @@ class Chef
166
172
 
167
173
  def knife_ssh
168
174
  ssh = Chef::Knife::Ssh.new
175
+ ssh.ui = ui
169
176
  ssh.name_args = [ server_name, ssh_command ]
170
177
  ssh.config[:ssh_user] = config[:ssh_user]
171
178
  ssh.config[:ssh_password] = config[:ssh_password]
@@ -1,4 +1,6 @@
1
1
  bash -c '
2
+ <%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
3
+
2
4
  if [ ! -f /usr/bin/chef-client ]; then
3
5
  pacman -Syy
4
6
  pacman -S --noconfirm ruby ntp base-devel
@@ -10,7 +12,7 @@ fi
10
12
  mkdir -p /etc/chef
11
13
  (
12
14
  cat <<'EOP'
13
- <%= IO.read(Chef::Config[:validation_key]) %>
15
+ <%= validation_key %>
14
16
  EOP
15
17
  ) > /tmp/validation.pem
16
18
  awk NF /tmp/validation.pem > /etc/chef/validation.pem
@@ -20,21 +22,22 @@ rm /tmp/validation.pem
20
22
  cat <<'EOP'
21
23
  log_level :info
22
24
  log_location STDOUT
23
- chef_server_url "<%= Chef::Config[:chef_server_url] %>"
24
- validation_client_name "<%= Chef::Config[:validation_client_name] %>"
25
- <% if @config[:chef_node_name] == nil %>
26
- # Using default node name (fqdn)
27
- <% else %>
25
+ chef_server_url "<%= @chef_config[:chef_server_url] %>"
26
+ validation_client_name "<%= @chef_config[:validation_client_name] %>"
27
+ <% if @config[:chef_node_name] -%>
28
28
  node_name "<%= @config[:chef_node_name] %>"
29
- <% end %>
30
- <% if Chef::Config[:environment] != nil %>
31
- environment "<%= Chef::Config[:environment]%>"
32
- <% end %>
29
+ <% else -%>
30
+ # Using default node name (fqdn)
31
+ <% end -%>
33
32
  # ArchLinux follows the Filesystem Hierarchy Standard
34
33
  file_cache_path "/var/cache/chef"
35
34
  file_backup_path "/var/lib/chef/backup"
36
35
  pid_file "/var/run/chef/client.pid"
37
36
  cache_options({ :path => "/var/cache/chef/checksums", :skip_expires => true})
37
+ <% if knife_config[:bootstrap_proxy] %>
38
+ http_proxy "<%= knife_config[:bootstrap_proxy] %>"
39
+ https_proxy "<%= knife_config[:bootstrap_proxy] %>"
40
+ <% end -%>
38
41
  EOP
39
42
  ) > /etc/chef/client.rb
40
43
 
@@ -44,5 +47,4 @@ cat <<'EOP'
44
47
  EOP
45
48
  ) > /etc/chef/first-boot.json
46
49
 
47
- /usr/bin/chef-client -j /etc/chef/first-boot.json
48
- '
50
+ <%= start_chef %>'