chef 0.10.0.beta.9 → 0.10.0.beta.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. data/README.rdoc +2 -0
  2. data/distro/common/html/chef-client.8.html +141 -0
  3. data/distro/common/html/chef-expander-cluster.8.html +164 -0
  4. data/distro/common/html/chef-expanderctl.8.html +146 -0
  5. data/distro/common/html/chef-server-webui.8.html +185 -0
  6. data/distro/common/html/chef-server.8.html +182 -0
  7. data/distro/common/html/chef-solo.8.html +191 -0
  8. data/distro/common/html/chef-solr.8.html +163 -0
  9. data/distro/common/html/knife-bootstrap.1.html +3 -3
  10. data/distro/common/html/knife-client.1.html +3 -3
  11. data/distro/common/html/knife-configure.1.html +1 -1
  12. data/distro/common/html/knife-cookbook-site.1.html +3 -3
  13. data/distro/common/html/knife-cookbook.1.html +3 -3
  14. data/distro/common/html/knife-data-bag.1.html +1 -1
  15. data/distro/common/html/knife-environment.1.html +3 -3
  16. data/distro/common/html/knife-exec.1.html +3 -3
  17. data/distro/common/html/knife-index.1.html +1 -1
  18. data/distro/common/html/knife-node.1.html +3 -3
  19. data/distro/common/html/knife-recipe.1.html +1 -1
  20. data/distro/common/html/knife-role.1.html +3 -3
  21. data/distro/common/html/knife-search.1.html +3 -3
  22. data/distro/common/html/knife-ssh.1.html +3 -3
  23. data/distro/common/html/knife-status.1.html +3 -3
  24. data/distro/common/html/knife-tag.1.html +3 -3
  25. data/distro/common/html/knife.1.html +3 -3
  26. data/distro/common/html/shef.1.html +3 -3
  27. data/distro/common/man/man1/knife-bootstrap.1 +1 -1
  28. data/distro/common/man/man1/knife-client.1 +1 -1
  29. data/distro/common/man/man1/knife-configure.1 +1 -1
  30. data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
  31. data/distro/common/man/man1/knife-cookbook.1 +1 -1
  32. data/distro/common/man/man1/knife-data-bag.1 +1 -1
  33. data/distro/common/man/man1/knife-environment.1 +1 -1
  34. data/distro/common/man/man1/knife-exec.1 +1 -1
  35. data/distro/common/man/man1/knife-index.1 +1 -1
  36. data/distro/common/man/man1/knife-node.1 +1 -1
  37. data/distro/common/man/man1/knife-role.1 +1 -1
  38. data/distro/common/man/man1/knife-search.1 +1 -1
  39. data/distro/common/man/man1/knife-ssh.1 +1 -1
  40. data/distro/common/man/man1/knife-status.1 +1 -1
  41. data/distro/common/man/man1/knife-tag.1 +1 -1
  42. data/distro/common/man/man1/knife.1 +1 -1
  43. data/distro/common/man/man1/shef.1 +1 -1
  44. data/distro/common/man/man8/chef-client.8 +53 -32
  45. data/distro/common/man/man8/chef-expander-cluster.8 +97 -0
  46. data/distro/common/man/man8/chef-expanderctl.8 +62 -0
  47. data/distro/common/man/man8/chef-server-webui.8 +121 -72
  48. data/distro/common/man/man8/chef-server.8 +113 -73
  49. data/distro/common/man/man8/chef-solo.8 +131 -30
  50. data/distro/common/man/man8/chef-solr.8 +85 -26
  51. data/distro/common/markdown/man8/chef-client.mkd +65 -0
  52. data/distro/common/markdown/man8/chef-expander-cluster.mkd +82 -0
  53. data/distro/common/markdown/man8/chef-expanderctl.mkd +58 -0
  54. data/distro/common/markdown/man8/chef-server-webui.mkd +121 -0
  55. data/distro/common/markdown/man8/chef-server.mkd +121 -0
  56. data/distro/common/markdown/man8/chef-solo.mkd +107 -0
  57. data/distro/common/markdown/man8/chef-solr.mkd +85 -0
  58. data/lib/chef/config.rb +1 -1
  59. data/lib/chef/cookbook/metadata.rb +1 -0
  60. data/lib/chef/cookbook_uploader.rb +12 -5
  61. data/lib/chef/couchdb.rb +21 -21
  62. data/lib/chef/file_access_control.rb +4 -4
  63. data/lib/chef/knife.rb +11 -3
  64. data/lib/chef/knife/bootstrap/centos5-gems.erb +13 -7
  65. data/lib/chef/knife/bootstrap/fedora13-gems.erb +1 -1
  66. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
  67. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +1 -1
  68. data/lib/chef/knife/client_create.rb +1 -1
  69. data/lib/chef/knife/configure.rb +10 -1
  70. data/lib/chef/knife/cookbook_bulk_delete.rb +13 -3
  71. data/lib/chef/knife/cookbook_site_download.rb +5 -5
  72. data/lib/chef/knife/cookbook_site_install.rb +5 -5
  73. data/lib/chef/knife/cookbook_site_list.rb +6 -2
  74. data/lib/chef/knife/cookbook_site_search.rb +1 -1
  75. data/lib/chef/knife/cookbook_site_show.rb +3 -3
  76. data/lib/chef/knife/cookbook_upload.rb +7 -8
  77. data/lib/chef/knife/core/ui.rb +1 -1
  78. data/lib/chef/knife/node_bulk_delete.rb +37 -3
  79. data/lib/chef/knife/recipe_list.rb +0 -1
  80. data/lib/chef/knife/role_bulk_delete.rb +27 -4
  81. data/lib/chef/mixin/language.rb +2 -2
  82. data/lib/chef/resource/deploy_revision.rb +5 -0
  83. data/lib/chef/rest.rb +5 -8
  84. data/lib/chef/version.rb +1 -1
  85. data/lib/chef/version_class.rb +4 -4
  86. metadata +20 -4
@@ -239,6 +239,6 @@ class Chef
239
239
  # Those lists of regular expressions define what chef considers a
240
240
  # valid user and group name
241
241
  user_valid_regex [ /^([-a-zA-Z0-9_.]+)$/, /^\d+$/ ]
242
- group_valid_regex [ /^([-a-zA-Z0-9_.]+)$/, /^\d+$/ ]
242
+ group_valid_regex [ /^([-a-zA-Z0-9_.\\ ]+)$/, /^\d+$/ ]
243
243
  end
244
244
  end
@@ -18,6 +18,7 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
+ require 'chef/mash'
21
22
  require 'chef/mixin/from_file'
22
23
  require 'chef/mixin/params_validate'
23
24
  require 'chef/mixin/check_helper'
@@ -1,4 +1,5 @@
1
1
 
2
+ require 'set'
2
3
  require 'rest_client'
3
4
  require 'chef/exceptions'
4
5
  require 'chef/knife/cookbook_metadata'
@@ -67,17 +68,22 @@ class Chef
67
68
 
68
69
  self.class.setup_worker_threads
69
70
 
71
+ checksums_to_upload = Set.new
72
+
70
73
  # upload the new checksums and commit the sandbox
71
74
  new_sandbox['checksums'].each do |checksum, info|
72
75
  if info['needs_upload'] == true
76
+ checksums_to_upload << checksum
73
77
  Chef::Log.info("Uploading #{checksum_files[checksum]} (checksum hex = #{checksum}) to #{info['url']}")
74
- self.class.work_queue << uploader_function_for(checksum_files[checksum], checksum, info['url'])
78
+ self.class.work_queue << uploader_function_for(checksum_files[checksum], checksum, info['url'], checksums_to_upload)
75
79
  else
76
80
  Chef::Log.debug("#{checksum_files[checksum]} has not changed")
77
81
  end
78
82
  end
79
83
 
80
- sleep 0.1 until self.class.work_queue.empty?
84
+ until checksums_to_upload.empty?
85
+ sleep 0.1
86
+ end
81
87
 
82
88
  sandbox_url = new_sandbox['uri']
83
89
  Chef::Log.debug("Committing sandbox")
@@ -102,14 +108,14 @@ class Chef
102
108
  def worker_thread(work_queue)
103
109
  end
104
110
 
105
- def uploader_function_for(file, checksum, url)
111
+ def uploader_function_for(file, checksum, url, checksums_to_upload)
106
112
  lambda do
107
113
  # Checksum is the hexadecimal representation of the md5,
108
114
  # but we need the base64 encoding for the content-md5
109
115
  # header
110
116
  checksum64 = Base64.encode64([checksum].pack("H*")).strip
111
117
  timestamp = Time.now.utc.iso8601
112
- file_contents = File.read(file)
118
+ file_contents = File.open(file, "rb") {|f| f.read}
113
119
  # TODO - 5/28/2010, cw: make signing and sending the request streaming
114
120
  sign_obj = Mixlib::Authentication::SignedHeaderAuth.signing_object(
115
121
  :http_method => :put,
@@ -123,8 +129,9 @@ class Chef
123
129
 
124
130
  begin
125
131
  RestClient::Resource.new(url, :headers=>headers, :timeout=>1800, :open_timeout=>1800).put(file_contents)
132
+ checksums_to_upload.delete(checksum)
126
133
  rescue RestClient::Exception => e
127
- Chef::Log.error("Upload failed: #{e.message}\n#{e.response.body}")
134
+ ui.error("Failed to upload #@cookbook : #{e.message}\n#{e.response.body}")
128
135
  raise
129
136
  end
130
137
  end
@@ -7,9 +7,9 @@
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
8
8
  # you may not use this file except in compliance with the License.
9
9
  # You may obtain a copy of the License at
10
- #
10
+ #
11
11
  # http://www.apache.org/licenses/LICENSE-2.0
12
- #
12
+ #
13
13
  # Unless required by applicable law or agreed to in writing, software
14
14
  # distributed under the License is distributed on an "AS IS" BASIS,
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -45,7 +45,7 @@ class Chef
45
45
 
46
46
  def create_id_map
47
47
  create_design_document(
48
- "id_map",
48
+ "id_map",
49
49
  {
50
50
  "version" => 1,
51
51
  "language" => "javascript",
@@ -59,7 +59,7 @@ class Chef
59
59
  },
60
60
  "id_to_name" => {
61
61
  "map" => <<-EOJS
62
- function(doc) {
62
+ function(doc) {
63
63
  emit(doc._id, [ doc.chef_type, doc.name ]);
64
64
  }
65
65
  EOJS
@@ -69,14 +69,14 @@ class Chef
69
69
  )
70
70
  end
71
71
 
72
- def create_db
72
+ def create_db(check_for_existing=true)
73
73
  @database_list = @rest.get_rest("_all_dbs")
74
- unless @database_list.detect { |db| db == couchdb_database }
74
+ if !check_for_existing || !@database_list.any? { |db| db == couchdb_database }
75
75
  response = @rest.put_rest(couchdb_database, Hash.new)
76
76
  end
77
77
  couchdb_database
78
78
  end
79
-
79
+
80
80
  def create_design_document(name, data)
81
81
  to_update = true
82
82
  begin
@@ -87,7 +87,7 @@ class Chef
87
87
  else
88
88
  to_update = false
89
89
  end
90
- rescue
90
+ rescue
91
91
  Chef::Log.debug("Creating #{name} views for the first time because: #{$!}")
92
92
  end
93
93
  if to_update
@@ -110,14 +110,14 @@ class Chef
110
110
  )
111
111
  rows = get_view("id_map", "name_to_id", :key => [ obj_type, name ])["rows"]
112
112
  uuid = rows.empty? ? UUIDTools::UUID.random_create.to_s : rows.first.fetch("id")
113
-
113
+
114
114
  db_put_response = @rest.put_rest("#{couchdb_database}/#{uuid}", object)
115
115
 
116
116
  if object.respond_to?(:add_to_index)
117
117
  Chef::Log.info("Sending #{obj_type}(#{uuid}) to the index queue for addition.")
118
118
  object.add_to_index(:database => couchdb_database, :id => uuid, :type => obj_type)
119
119
  end
120
-
120
+
121
121
  db_put_response
122
122
  end
123
123
 
@@ -134,9 +134,9 @@ class Chef
134
134
  )
135
135
  doc = find_by_name(obj_type, name)
136
136
  doc.couchdb = self if doc.respond_to?(:couchdb)
137
- doc
137
+ doc
138
138
  end
139
-
139
+
140
140
  def delete(obj_type, name, rev=nil)
141
141
  validate(
142
142
  {
@@ -148,7 +148,7 @@ class Chef
148
148
  :name => { :kind_of => String },
149
149
  }
150
150
  )
151
- del_id = nil
151
+ del_id = nil
152
152
  object, uuid = find_by_name(obj_type, name, true)
153
153
  unless rev
154
154
  if object.respond_to?(:couchdb_rev)
@@ -159,7 +159,7 @@ class Chef
159
159
  end
160
160
  response = @rest.delete_rest("#{couchdb_database}/#{uuid}?rev=#{rev}")
161
161
  response.couchdb = self if response.respond_to?(:couchdb=)
162
-
162
+
163
163
  if object.respond_to?(:delete_from_index)
164
164
  Chef::Log.info("Sending #{obj_type}(#{uuid}) to the index queue for deletion..")
165
165
  object.delete_from_index(:database => couchdb_database, :id => uuid, :type => obj_type)
@@ -167,10 +167,10 @@ class Chef
167
167
 
168
168
  response
169
169
  end
170
-
170
+
171
171
  def list(view, inflate=false)
172
172
  validate(
173
- {
173
+ {
174
174
  :view => view,
175
175
  },
176
176
  {
@@ -186,7 +186,7 @@ class Chef
186
186
  end
187
187
  r
188
188
  end
189
-
189
+
190
190
  def has_key?(obj_type, name)
191
191
  validate(
192
192
  {
@@ -214,7 +214,7 @@ class Chef
214
214
  if with_id
215
215
  [ r["rows"][0]["doc"], r["rows"][0]["id"] ]
216
216
  else
217
- r["rows"][0]["doc"]
217
+ r["rows"][0]["doc"]
218
218
  end
219
219
  end
220
220
 
@@ -229,7 +229,7 @@ class Chef
229
229
  response = @rest.post_rest("#{couchdb_database}/_all_docs?include_docs=true", { "keys" => to_fetch.flatten })
230
230
  response["rows"].collect { |r| r["doc"] }
231
231
  end
232
-
232
+
233
233
  def view_uri(design, view)
234
234
  "#{couchdb_database}/_design/#{design}/_view/#{view}"
235
235
  end
@@ -237,10 +237,10 @@ class Chef
237
237
  def server_stats
238
238
  @rest.get_rest('/')
239
239
  end
240
-
240
+
241
241
  def db_stats
242
242
  @rest.get_rest("/#{@db}")
243
243
  end
244
-
244
+
245
245
  end
246
246
  end
@@ -26,7 +26,7 @@ class Chef
26
26
  # the values specified by a value object, usually a Chef::Resource.
27
27
  class FileAccessControl
28
28
  UINT = (1 << 32)
29
- UID_MAX = (1 << 31)
29
+ UID_MAX = (1 << 32) - 10
30
30
 
31
31
  attr_reader :resource
32
32
 
@@ -60,7 +60,7 @@ class Chef
60
60
  # Workaround the fact that Ruby's Etc module doesn't believe in negative
61
61
  # uids, so negative uids show up as the diminished radix complement of
62
62
  # a uint. For example, a uid of -2 is reported as 4294967294
63
- def dimished_radix_complement(int)
63
+ def diminished_radix_complement(int)
64
64
  if int > UID_MAX
65
65
  int - UINT
66
66
  else
@@ -71,7 +71,7 @@ class Chef
71
71
  def target_uid
72
72
  return nil if resource.owner.nil?
73
73
  if resource.owner.kind_of?(String)
74
- dimished_radix_complement( Etc.getpwnam(resource.owner).uid )
74
+ diminished_radix_complement( Etc.getpwnam(resource.owner).uid )
75
75
  elsif resource.owner.kind_of?(Integer)
76
76
  resource.owner
77
77
  else
@@ -93,7 +93,7 @@ class Chef
93
93
  def target_gid
94
94
  return nil if resource.group.nil?
95
95
  if resource.group.kind_of?(String)
96
- dimished_radix_complement( Etc.getgrnam(resource.group).gid )
96
+ diminished_radix_complement( Etc.getgrnam(resource.group).gid )
97
97
  elsif resource.group.kind_of?(Integer)
98
98
  resource.group
99
99
  else
@@ -288,7 +288,8 @@ class Chef
288
288
  read_config_file(config[:config_file])
289
289
  else
290
290
  # ...but do log a message if no config was found.
291
- self.msg("No knife configuration file found")
291
+ Chef::Config[:color] = config[:color] && !config[:no_color]
292
+ ui.warn("No knife configuration file found")
292
293
  end
293
294
 
294
295
  Chef::Config[:color] = config[:color] && !config[:no_color]
@@ -320,7 +321,7 @@ class Chef
320
321
  Chef::Log.debug("Using configuration from #{config[:config_file]}")
321
322
 
322
323
  if Chef::Config[:node_name].nil?
323
- raise ArgumentError, "No user specified, pass via -u or specifiy 'node_name' in #{config[:config_file] ? config[:config_file] : "~/.chef/knife.rb"}"
324
+ #raise ArgumentError, "No user specified, pass via -u or specifiy 'node_name' in #{config[:config_file] ? config[:config_file] : "~/.chef/knife.rb"}"
324
325
  end
325
326
  end
326
327
 
@@ -476,7 +477,7 @@ class Chef
476
477
  output(format_for_display(object)) if config[:print_after]
477
478
 
478
479
  obj_name = delete_name ? "#{delete_name}[#{name}]" : object
479
- self.msg("Deleted #{obj_name}!")
480
+ self.msg("Deleted #{obj_name}")
480
481
  end
481
482
 
482
483
  def bulk_delete(klass, fancy_name, delete_name=nil, list=nil, regex=nil, &block)
@@ -514,6 +515,13 @@ class Chef
514
515
  end
515
516
  end
516
517
 
518
+ def noauth_rest
519
+ @rest ||= begin
520
+ require 'chef/rest'
521
+ Chef::REST.new(Chef::Config[:chef_server_url], false, false)
522
+ end
523
+ end
524
+
517
525
  def server_url
518
526
  Chef::Config[:chef_server_url]
519
527
  end
@@ -1,11 +1,17 @@
1
1
  bash -c '
2
- rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
3
- rpm -Uvh http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
2
+ if [ ! -f /usr/bin/chef-client ]; then
3
+ rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
4
+ rpm -Uvh http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
4
5
 
5
- yum install -q -y ruby ruby-devel gcc gcc-c++ automake autoconf rubygems make
6
+ yum install -q -y ruby ruby-devel gcc gcc-c++ automake autoconf make
7
+
8
+ cd /tmp
9
+ wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
10
+ tar zxf rubygems-1.3.7.tgz
11
+ cd rubygems-1.3.7
12
+ ruby setup.rb --no-format-executable
13
+ fi
6
14
 
7
- gem update --system
8
- gem update
9
15
  gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
10
16
 
11
17
  mkdir -p /etc/chef
@@ -25,10 +31,10 @@ log_location STDOUT
25
31
  chef_server_url "<%= Chef::Config[:chef_server_url] %>"
26
32
  validation_client_name "<%= Chef::Config[:validation_client_name] %>"
27
33
  <% if @config[:chef_node_name] == nil %>
28
- # Using default node name"
34
+ # Using default node name (fqdn)
29
35
  <% else %>
30
36
  node_name "<%= @config[:chef_node_name] %>"
31
- <% end %>
37
+ <% end %>
32
38
  EOP
33
39
  ) > /etc/chef/client.rb
34
40
 
@@ -25,7 +25,7 @@ validation_client_name "<%= Chef::Config[:validation_client_name] %>"
25
25
  # Using default node name"
26
26
  <% else %>
27
27
  node_name "<%= @config[:chef_node_name] %>"
28
- <% end %>
28
+ <% end %>
29
29
  EOP
30
30
  ) > /etc/chef/client.rb
31
31
 
@@ -1,6 +1,6 @@
1
1
  bash -c '
2
2
  if [ ! -f /usr/bin/chef-client ]; then
3
- echo "chef chef/chef_server_url string <%= Chef::Config[:chef_server_url] %>" | debconf-set-selections
3
+ echo "chef chef/chef_server_url string <%= Chef::Config[:chef_server_url] %>" | debconf-set-selections
4
4
  [ -f /etc/apt/sources.list.d/opscode.list ] || echo "deb http://apt.opscode.com lucid main" > /etc/apt/sources.list.d/opscode.list
5
5
  wget -O- http://apt.opscode.com/packages@opscode.com.gpg.key | apt-key add -
6
6
  fi
@@ -21,7 +21,7 @@ rm /tmp/validation.pem
21
21
 
22
22
  <% if @config[:chef_node_name] %>
23
23
  [ `grep -qx "node_name \"<%= @config[:chef_node_name] %>\"" /etc/chef/client.rb` ] || echo "node_name \"<%= @config[:chef_node_name] %>\"" >> /etc/chef/client.rb
24
- <% end -%>
24
+ <% end -%>
25
25
 
26
26
  (
27
27
  cat <<'EOP'
@@ -27,7 +27,7 @@ log_location STDOUT
27
27
  chef_server_url "<%= Chef::Config[:chef_server_url] %>"
28
28
  validation_client_name "<%= Chef::Config[:validation_client_name] %>"
29
29
  <% if @config[:chef_node_name] == nil %>
30
- # Using default node name"
30
+ # Using default node name (fqdn)
31
31
  <% else %>
32
32
  node_name "<%= @config[:chef_node_name] %>"
33
33
  <% end %>
@@ -57,7 +57,7 @@ class Chef
57
57
 
58
58
  key = output.save
59
59
 
60
- ui.info("Created (or updated) #{output}")
60
+ ui.info("Created #{output}")
61
61
 
62
62
  if config[:file]
63
63
  File.open(config[:file], "w") do |f|
@@ -25,6 +25,7 @@ class Chef
25
25
  attr_reader :chef_repo, :new_client_key, :validation_client_name, :validation_key
26
26
 
27
27
  deps do
28
+ require 'ohai'
28
29
  Chef::Knife::ClientCreate.load_deps
29
30
  end
30
31
 
@@ -113,7 +114,8 @@ EOH
113
114
  end
114
115
 
115
116
  def ask_user_for_config
116
- @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => 'http://localhost:4000')
117
+ server_name = guess_servername
118
+ @chef_server = config[:chef_server_url] || ask_question("Please enter the chef server URL: ", :default => "http://#{server_name}:4000")
117
119
  if config[:initial]
118
120
  @new_client_name = config[:node_name] || ask_question("Please enter a clientname for the new client: ", :default => Etc.getlogin)
119
121
  @admin_client_name = config[:admin_client_name] || ask_question("Please enter the existing admin clientname: ", :default => 'chef-webui')
@@ -128,6 +130,13 @@ EOH
128
130
  @new_client_key = config[:client_key] || File.join(chef_config_path, "#{@new_client_name}.pem")
129
131
  end
130
132
 
133
+ def guess_servername
134
+ o = Ohai::System.new
135
+ o.require_plugin 'os'
136
+ o.require_plugin 'hostname'
137
+ o[:fqdn] || 'localhost'
138
+ end
139
+
131
140
  def config_file
132
141
  config[:config_file]
133
142
  end
@@ -43,11 +43,21 @@ class Chef
43
43
  all_cookbooks = Chef::CookbookVersion.list
44
44
  cookbooks_names = all_cookbooks.keys.grep(regex)
45
45
  cookbooks_to_delete = cookbooks_names.inject({}) { |hash, name| hash[name] = all_cookbooks[name];hash }
46
- output(format_list_for_display(cookbooks_to_delete))
46
+ ui.msg "All versions of the following cookbooks will be deleted:"
47
+ ui.msg ""
48
+ ui.msg ui.list(cookbooks_to_delete.keys.sort, :columns_down)
49
+ ui.msg ""
47
50
 
48
- ui.confirm("Do you really want to delete these cookbooks? All versions will be deleted. (Y/N) ", false)
51
+ unless config[:yes]
52
+ ui.confirm("Do you really want to delete these cookbooks? (Y/N) ", false)
53
+
54
+ if config[:purge]
55
+ ui.msg("Files that are common to multiple cookbooks are shared, so purging the files may break other cookbooks.")
56
+ ui.confirm("Are you sure you want to purge files instead of just deleting the cookbooks")
57
+ end
58
+ ui.msg ""
59
+ end
49
60
 
50
- ui.confirm("Files that are common to multiple cookbooks are shared, so purging the files may disable other cookbooks. Are you sure you want to purge files instead of just deleting the cookbooks") if config[:purge]
51
61
 
52
62
  cookbooks_names.each do |cookbook_name|
53
63
  versions = rest.get_rest("cookbooks/#{cookbook_name}")[cookbook_name]["versions"].map {|v| v["version"]}.flatten
@@ -33,17 +33,17 @@ class Chef
33
33
 
34
34
  def run
35
35
  if @name_args.length == 1
36
- current = rest.get_rest("http://cookbooks.opscode.com/api/v1/cookbooks/#{name_args[0]}")
37
- cookbook_data = rest.get_rest(current["latest_version"])
36
+ current = noauth_rest.get_rest("http://cookbooks.opscode.com/api/v1/cookbooks/#{name_args[0]}")
37
+ cookbook_data = noauth_rest.get_rest(current["latest_version"])
38
38
  else
39
- cookbook_data = rest.get_rest("http://cookbooks.opscode.com/api/v1/cookbooks/#{name_args[0]}/versions/#{name_args[1].gsub('.', '_')}")
39
+ cookbook_data = noauth_rest.get_rest("http://cookbooks.opscode.com/api/v1/cookbooks/#{name_args[0]}/versions/#{name_args[1].gsub('.', '_')}")
40
40
  end
41
41
 
42
42
  @version = cookbook_data['version']
43
43
 
44
44
  ui.info("Downloading #{@name_args[0]} from the cookbooks site at version #{cookbook_data['version']} to #{config[:file]}")
45
- rest.sign_on_redirect = false
46
- tf = rest.get_rest(cookbook_data["file"], true)
45
+ noauth_rest.sign_on_redirect = false
46
+ tf = noauth_rest.get_rest(cookbook_data["file"], true)
47
47
  unless config[:file]
48
48
  config[:file] = File.join(Dir.pwd, "#{@name_args[0]}-#{cookbook_data['version']}.tar.gz")
49
49
  end