chef 15.6.10-universal-mingw32 → 15.7.30-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +22 -5
- data/lib/chef/cookbook/cookbook_version_loader.rb +12 -6
- data/lib/chef/cookbook_loader.rb +55 -2
- data/lib/chef/cookbook_uploader.rb +2 -0
- data/lib/chef/cookbook_version.rb +17 -0
- data/lib/chef/dist.rb +3 -3
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/knife/bootstrap.rb +5 -0
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +11 -11
- data/lib/chef/knife/cookbook_upload.rb +75 -45
- data/lib/chef/knife/core/bootstrap_context.rb +5 -5
- data/lib/chef/knife/core/windows_bootstrap_context.rb +1 -1
- data/lib/chef/knife/supermarket_install.rb +1 -1
- data/lib/chef/log/winevt.rb +1 -1
- data/lib/chef/mixin/openssl_helper.rb +21 -0
- data/lib/chef/monkey_patches/net_http.rb +0 -38
- data/lib/chef/provider/cron.rb +54 -9
- data/lib/chef/provider/cron/aix.rb +9 -2
- data/lib/chef/provider/launchd.rb +1 -1
- data/lib/chef/provider/user/aix.rb +1 -1
- data/lib/chef/provider/user/mac.rb +17 -22
- data/lib/chef/provider/windows_task.rb +2 -2
- data/lib/chef/resource/archive_file.rb +5 -2
- data/lib/chef/resource/cron.rb +29 -0
- data/lib/chef/resource/cron_d.rb +29 -0
- data/lib/chef/resource/openssl_x509_certificate.rb +32 -21
- data/lib/chef/resource/sudo.rb +13 -4
- data/lib/chef/version.rb +2 -2
- data/lib/chef/version_string.rb +3 -126
- data/spec/data/cookbooks/apache2/metadata.json +33 -0
- data/spec/data/cookbooks/java/metadata.json +33 -0
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +5 -5
- data/spec/integration/knife/chef_fs_data_store_spec.rb +7 -2
- data/spec/integration/knife/cookbook_upload_spec.rb +10 -0
- data/spec/integration/knife/deps_spec.rb +11 -0
- data/spec/integration/knife/upload_spec.rb +115 -14
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +7 -4
- data/spec/unit/knife/cookbook_upload_spec.rb +79 -18
- data/spec/unit/mixin/openssl_helper_spec.rb +42 -0
- data/spec/unit/provider/cron_spec.rb +127 -0
- data/spec/unit/provider/user/aix_spec.rb +2 -2
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76f64193363de1b7f06e3cab207a3c3c76fc3213025e25ca47f8a075f72017da
|
4
|
+
data.tar.gz: 598c10f55946daa0192ff28b9d32c7419477cd53ad26fe61bbd04fa5af8a4e84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d0880494a7dbb23ed118d8887107b411b7961c61c4fb50d78acb1a792ba0d9e16c1565a1fcb8be14b943253f1d83f58a7d1a6f36d599b4eaab55ce002b8c71e
|
7
|
+
data.tar.gz: 99a2b493cc44877b242e9a733613f9e74074ba8369a590e109b833cf8a97d9d2640a88d295f5da0859078e91cb6ee694d9cf079da81f09f3a72170b4b1afbe5b
|
data/Gemfile
CHANGED
@@ -8,7 +8,7 @@ source "https://rubygems.org"
|
|
8
8
|
gem "chef", path: "."
|
9
9
|
|
10
10
|
# necessary until we release ohai 15
|
11
|
-
gem "ohai", git: "https://github.com/chef/ohai.git", branch: "
|
11
|
+
gem "ohai", git: "https://github.com/chef/ohai.git", branch: "15-stable"
|
12
12
|
|
13
13
|
gem "chef-utils", path: File.expand_path("../chef-utils", __FILE__) if File.exist?(File.expand_path("../chef-utils", __FILE__))
|
14
14
|
gem "chef-config", path: File.expand_path("../chef-config", __FILE__) if File.exist?(File.expand_path("../chef-config", __FILE__))
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Chef Infra
|
2
2
|
[![Code Climate](https://codeclimate.com/github/chef/chef.svg)](https://codeclimate.com/github/chef/chef)
|
3
|
-
[![Build
|
3
|
+
[![Build status](https://badge.buildkite.com/13b36bf2d9116e3527ff9893e7edd82cb183027941fef3d24e.svg)](https://buildkite.com/chef-oss/chef-chef-chef-15-verify)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef)
|
5
5
|
[![](https://img.shields.io/badge/Release%20Policy-Cadence%20Release-brightgreen.svg)](https://github.com/chef/chef/blob/v15.2.21/docs/dev/design_documents/client_release_cadence.md)
|
6
6
|
|
@@ -32,7 +32,7 @@ Other useful resources for Chef Infra users:
|
|
32
32
|
|
33
33
|
Issues can be reported by using [GitHub Issues](https://github.com/chef/chef/issues).
|
34
34
|
|
35
|
-
Note that this repository is primarily for reporting issues in the chef-client itself.
|
35
|
+
Note that this repository is primarily for reporting issues in the chef-client itself. For reporting issues against other Chef projects, please look up the appropriate repository. If you're unsure where to submit an issue, please ask in the #chef-dev channel in [Chef Community Slack](https://community-slack.chef.io/).
|
36
36
|
|
37
37
|
## How We Build & Release Chef
|
38
38
|
|
@@ -72,12 +72,29 @@ class Chef
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def upload_cookbook(other, options)
|
75
|
-
|
76
|
-
|
77
|
-
uploader = Chef::CookbookUploader.new(cookbook_to_upload, force: options[:force], rest: chef_rest)
|
75
|
+
cookbook = other.chef_object if other.chef_object
|
76
|
+
raise Chef::Exceptions::MetadataNotFound.new(cookbook.root_paths[0], cookbook.name) unless cookbook.has_metadata_file?
|
78
77
|
|
79
|
-
|
80
|
-
|
78
|
+
if cookbook
|
79
|
+
begin
|
80
|
+
tmp_cl = Chef::CookbookLoader.copy_to_tmp_dir_from_array([cookbook])
|
81
|
+
tmp_cl.load_cookbooks
|
82
|
+
tmp_cl.compile_metadata
|
83
|
+
tmp_cl.freeze_versions if options[:freeze]
|
84
|
+
cookbook_for_upload = []
|
85
|
+
tmp_cl.each do |cookbook_name, cookbook|
|
86
|
+
cookbook_for_upload << cookbook
|
87
|
+
end
|
88
|
+
|
89
|
+
uploader = Chef::CookbookUploader.new(cookbook_for_upload, force: options[:force], rest: chef_rest)
|
90
|
+
|
91
|
+
with_actual_cookbooks_dir(other.parent.file_path) do
|
92
|
+
uploader.upload_cookbooks
|
93
|
+
end
|
94
|
+
|
95
|
+
ensure
|
96
|
+
tmp_cl.unlink!
|
97
|
+
end
|
81
98
|
end
|
82
99
|
end
|
83
100
|
|
@@ -65,19 +65,24 @@ class Chef
|
|
65
65
|
# Load the cookbook. Raises an error if the cookbook_path given to the
|
66
66
|
# constructor doesn't point to a valid cookbook.
|
67
67
|
def load!
|
68
|
-
|
68
|
+
metadata # force lazy evaluation to occur
|
69
|
+
|
70
|
+
# re-raise any exception that occurred when reading the metadata
|
71
|
+
raise_metadata_error!
|
72
|
+
|
73
|
+
load_all_files
|
74
|
+
|
75
|
+
remove_ignored_files
|
69
76
|
|
70
77
|
if empty?
|
71
78
|
raise Exceptions::CookbookNotFoundInRepo, "The directory #{cookbook_path} does not contain a cookbook"
|
72
79
|
end
|
73
80
|
|
74
|
-
|
81
|
+
cookbook_settings
|
75
82
|
end
|
76
83
|
|
77
|
-
# Load the cookbook. Does not raise an error if given a non-cookbook
|
78
|
-
# directory as the cookbook_path. This behavior is provided for
|
79
|
-
# compatibility, it is recommended to use #load! instead.
|
80
84
|
def load
|
85
|
+
Chef::Log.warn "load method is deprecated. Use load! instead"
|
81
86
|
metadata # force lazy evaluation to occur
|
82
87
|
|
83
88
|
# re-raise any exception that occurred when reading the metadata
|
@@ -88,8 +93,9 @@ class Chef
|
|
88
93
|
remove_ignored_files
|
89
94
|
|
90
95
|
if empty?
|
91
|
-
|
96
|
+
raise Exceptions::CookbookNotFoundInRepo, "The directory #{cookbook_path} does not contain a cookbook"
|
92
97
|
end
|
98
|
+
|
93
99
|
cookbook_settings
|
94
100
|
end
|
95
101
|
|
data/lib/chef/cookbook_loader.rb
CHANGED
@@ -44,11 +44,14 @@ class Chef
|
|
44
44
|
# @return [Array<String>] the array of repo paths containing cookbook dirs
|
45
45
|
attr_reader :repo_paths
|
46
46
|
|
47
|
+
attr_accessor :tmp_working_dir_path
|
48
|
+
|
47
49
|
# XXX: this is highly questionable combined with the Hash-style each method
|
48
50
|
include Enumerable
|
49
51
|
|
50
52
|
# @param repo_paths [Array<String>] the array of repo paths containing cookbook dirs
|
51
53
|
def initialize(*repo_paths)
|
54
|
+
@tmp_working_dir_path = nil
|
52
55
|
@repo_paths = repo_paths.flatten.compact.map { |p| File.expand_path(p) }
|
53
56
|
raise ArgumentError, "You must specify at least one cookbook repo path" if @repo_paths.empty?
|
54
57
|
end
|
@@ -92,11 +95,11 @@ class Chef
|
|
92
95
|
|
93
96
|
loader = cookbook_version_loaders[cookbook_name]
|
94
97
|
|
95
|
-
loader.load
|
98
|
+
loader.load!
|
96
99
|
|
97
100
|
cookbook_version = loader.cookbook_version
|
98
101
|
cookbooks_by_name[cookbook_name] = cookbook_version
|
99
|
-
metadata[cookbook_name] = cookbook_version.metadata
|
102
|
+
metadata[cookbook_name] = cookbook_version.metadata unless cookbook_version.nil?
|
100
103
|
cookbook_version
|
101
104
|
end
|
102
105
|
|
@@ -135,6 +138,56 @@ class Chef
|
|
135
138
|
cookbooks_by_name.values
|
136
139
|
end
|
137
140
|
|
141
|
+
# This method creates tmp directory and copies all cookbooks into it and creates cookbook loder object which points to tmp directory
|
142
|
+
def self.copy_to_tmp_dir_from_array(cookbooks)
|
143
|
+
tmp_cookbook_file = Tempfile.new("tmp_working_dir_path")
|
144
|
+
tmp_cookbook_file.close
|
145
|
+
@tmp_working_dir_path = tmp_cookbook_file.path
|
146
|
+
File.unlink(@tmp_working_dir_path)
|
147
|
+
FileUtils.mkdir_p(@tmp_working_dir_path)
|
148
|
+
cookbooks.each do |cookbook|
|
149
|
+
checksums_to_on_disk_paths = cookbook.checksums
|
150
|
+
cookbook.each_file do |manifest_record|
|
151
|
+
path_in_cookbook = manifest_record[:path]
|
152
|
+
on_disk_path = checksums_to_on_disk_paths[manifest_record[:checksum]]
|
153
|
+
dest = File.join(@tmp_working_dir_path, cookbook.name.to_s, path_in_cookbook)
|
154
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
155
|
+
FileUtils.cp_r(on_disk_path, dest)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
tmp_cookbook_loader ||= begin
|
159
|
+
Chef::Cookbook::FileVendor.fetch_from_disk(@tmp_working_dir_path)
|
160
|
+
CookbookLoader.new(@tmp_working_dir_path)
|
161
|
+
end
|
162
|
+
tmp_cookbook_loader.tmp_working_dir_path = @tmp_working_dir_path
|
163
|
+
tmp_cookbook_loader
|
164
|
+
end
|
165
|
+
|
166
|
+
# generates metadata.json adds it in the manifest
|
167
|
+
def compile_metadata
|
168
|
+
each do |cookbook_name, cookbook|
|
169
|
+
compiled_metadata = cookbook.compile_metadata
|
170
|
+
if compiled_metadata
|
171
|
+
cookbook.all_files << compiled_metadata
|
172
|
+
cookbook.cookbook_manifest.send(:generate_manifest)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# freeze versions of all the cookbooks
|
178
|
+
def freeze_versions
|
179
|
+
each do |cookbook_name, cookbook|
|
180
|
+
cookbook.freeze_version
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
# removes the tmp_dir_path
|
185
|
+
def unlink!
|
186
|
+
raise "Invalid directory path." if @tmp_working_dir_path.nil?
|
187
|
+
|
188
|
+
FileUtils.rm_rf(@tmp_working_dir_path)
|
189
|
+
end
|
190
|
+
|
138
191
|
alias :cookbooks :values
|
139
192
|
|
140
193
|
private
|
@@ -139,6 +139,8 @@ class Chef
|
|
139
139
|
|
140
140
|
def validate_cookbooks
|
141
141
|
cookbooks.each do |cb|
|
142
|
+
next if cb.nil?
|
143
|
+
|
142
144
|
syntax_checker = Chef::Cookbook::SyntaxCheck.new(cb.root_dir)
|
143
145
|
Chef::Log.info("Validating ruby files")
|
144
146
|
exit(1) unless syntax_checker.validate_ruby_files
|
@@ -445,6 +445,10 @@ class Chef
|
|
445
445
|
end
|
446
446
|
end
|
447
447
|
|
448
|
+
def has_metadata_file?
|
449
|
+
all_files.include?(metadata_json_file) || all_files.include?(metadata_rb_file)
|
450
|
+
end
|
451
|
+
|
448
452
|
##
|
449
453
|
# REST API
|
450
454
|
##
|
@@ -513,6 +517,19 @@ class Chef
|
|
513
517
|
@cookbook_manifest ||= CookbookManifest.new(self)
|
514
518
|
end
|
515
519
|
|
520
|
+
def compile_metadata(path = root_dir)
|
521
|
+
json_file = "#{path}/metadata.json"
|
522
|
+
rb_file = "#{path}/metadata.rb"
|
523
|
+
return nil if File.exist?(json_file)
|
524
|
+
|
525
|
+
md = Chef::Cookbook::Metadata.new
|
526
|
+
md.from_file(rb_file)
|
527
|
+
f = File.open(json_file, "w")
|
528
|
+
f.write(Chef::JSONCompat.to_json_pretty(md))
|
529
|
+
f.close
|
530
|
+
f.path
|
531
|
+
end
|
532
|
+
|
516
533
|
private
|
517
534
|
|
518
535
|
def find_preferred_manifest_record(node, segment, filename)
|
data/lib/chef/dist.rb
CHANGED
@@ -9,13 +9,13 @@ class Chef
|
|
9
9
|
|
10
10
|
# A short designation for the product, used in Windows event logs
|
11
11
|
# and some nomenclature.
|
12
|
-
SHORT =
|
12
|
+
SHORT = ChefConfig::Dist::SHORT.freeze
|
13
13
|
|
14
14
|
# The name of the server product
|
15
15
|
SERVER_PRODUCT = "Chef Infra Server".freeze
|
16
16
|
|
17
17
|
# The client's alias (chef-client)
|
18
|
-
CLIENT =
|
18
|
+
CLIENT = ChefConfig::Dist::CLIENT.freeze
|
19
19
|
|
20
20
|
# name of the automate product
|
21
21
|
AUTOMATE = "Chef Automate".freeze
|
@@ -52,7 +52,7 @@ class Chef
|
|
52
52
|
CONF_DIR = ChefConfig::Config.etc_chef_dir.freeze
|
53
53
|
|
54
54
|
# The user's configuration directory
|
55
|
-
USER_CONF_DIR =
|
55
|
+
USER_CONF_DIR = ChefConfig::Dist::USER_CONF_DIR.freeze
|
56
56
|
|
57
57
|
# The server's configuration directory
|
58
58
|
SERVER_CONF_DIR = "/etc/chef-server".freeze
|
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -296,6 +296,11 @@ class Chef
|
|
296
296
|
description: "URL to a custom installation script.",
|
297
297
|
proc: Proc.new { |u| Chef::Config[:knife][:bootstrap_url] = u }
|
298
298
|
|
299
|
+
option :bootstrap_product,
|
300
|
+
long: "--bootstrap-product PRODUCT",
|
301
|
+
description: "Product to install.",
|
302
|
+
default: "chef"
|
303
|
+
|
299
304
|
option :msi_url, # Windows target only
|
300
305
|
short: "-m URL",
|
301
306
|
long: "--msi-url URL",
|
@@ -177,7 +177,7 @@ do_download() {
|
|
177
177
|
else
|
178
178
|
echo "-----> Installing Chef Omnibus (<%= @config[:channel] %>/<%= version_to_install %>)"
|
179
179
|
do_download ${install_sh} $tmp_dir/install.sh
|
180
|
-
sh $tmp_dir/install.sh -P
|
180
|
+
sh $tmp_dir/install.sh -P <%= @config[:bootstrap_product] %> -c <%= @config[:channel] %> -v <%= version_to_install %>
|
181
181
|
fi
|
182
182
|
<% end %>
|
183
183
|
|
@@ -185,55 +185,55 @@ if test "x$tmp_dir" != "x"; then
|
|
185
185
|
rm -r "$tmp_dir"
|
186
186
|
fi
|
187
187
|
|
188
|
-
mkdir -p
|
188
|
+
mkdir -p /etc/chef
|
189
189
|
|
190
190
|
<% if client_pem -%>
|
191
|
-
(umask 077 && (cat >
|
191
|
+
(umask 077 && (cat > /etc/chef/client.pem <<'EOP'
|
192
192
|
<%= ::File.read(::File.expand_path(client_pem)) %>
|
193
193
|
EOP
|
194
194
|
)) || exit 1
|
195
195
|
<% end -%>
|
196
196
|
|
197
197
|
<% if validation_key -%>
|
198
|
-
(umask 077 && (cat >
|
198
|
+
(umask 077 && (cat > /etc/chef/validation.pem <<'EOP'
|
199
199
|
<%= validation_key %>
|
200
200
|
EOP
|
201
201
|
)) || exit 1
|
202
202
|
<% end -%>
|
203
203
|
|
204
204
|
<% if encrypted_data_bag_secret -%>
|
205
|
-
(umask 077 && (cat >
|
205
|
+
(umask 077 && (cat > /etc/chef/encrypted_data_bag_secret <<'EOP'
|
206
206
|
<%= encrypted_data_bag_secret %>
|
207
207
|
EOP
|
208
208
|
)) || exit 1
|
209
209
|
<% end -%>
|
210
210
|
|
211
211
|
<% unless trusted_certs.empty? -%>
|
212
|
-
mkdir -p
|
212
|
+
mkdir -p /etc/chef/trusted_certs
|
213
213
|
<%= trusted_certs %>
|
214
214
|
<% end -%>
|
215
215
|
|
216
216
|
<%# Generate Ohai Hints -%>
|
217
217
|
<% unless @chef_config[:knife][:hints].nil? || @chef_config[:knife][:hints].empty? -%>
|
218
|
-
mkdir -p
|
218
|
+
mkdir -p /etc/chef/ohai/hints
|
219
219
|
|
220
220
|
<% @chef_config[:knife][:hints].each do |name, hash| -%>
|
221
|
-
cat >
|
221
|
+
cat > /etc/chef/ohai/hints/<%= name %>.json <<'EOP'
|
222
222
|
<%= Chef::JSONCompat.to_json(hash) %>
|
223
223
|
EOP
|
224
224
|
<% end -%>
|
225
225
|
<% end -%>
|
226
226
|
|
227
|
-
cat >
|
227
|
+
cat > /etc/chef/client.rb <<'EOP'
|
228
228
|
<%= config_content %>
|
229
229
|
EOP
|
230
230
|
|
231
|
-
cat >
|
231
|
+
cat > /etc/chef/first-boot.json <<'EOP'
|
232
232
|
<%= Chef::JSONCompat.to_json(first_boot) %>
|
233
233
|
EOP
|
234
234
|
|
235
235
|
<% unless client_d.empty? -%>
|
236
|
-
mkdir -p
|
236
|
+
mkdir -p /etc/chef/client.d
|
237
237
|
<%= client_d %>
|
238
238
|
<% end -%>
|
239
239
|
|
@@ -20,11 +20,14 @@
|
|
20
20
|
|
21
21
|
require_relative "../knife"
|
22
22
|
require_relative "../cookbook_uploader"
|
23
|
+
require_relative "../mixin/file_class"
|
23
24
|
|
24
25
|
class Chef
|
25
26
|
class Knife
|
26
27
|
class CookbookUpload < Knife
|
27
28
|
|
29
|
+
include Chef::Mixin::FileClass
|
30
|
+
|
28
31
|
CHECKSUM = "checksum".freeze
|
29
32
|
MATCH_CHECKSUM = /[0-9a-f]{32,}/.freeze
|
30
33
|
|
@@ -93,57 +96,84 @@ class Chef
|
|
93
96
|
# to check for the existence of a cookbook's dependencies.
|
94
97
|
@server_side_cookbooks = Chef::CookbookVersion.list_all_versions
|
95
98
|
justify_width = @server_side_cookbooks.map(&:size).max.to_i + 2
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
if cookbooks_for_upload.any?
|
105
|
-
begin
|
106
|
-
upload(cookbooks_for_upload, justify_width)
|
107
|
-
rescue Exceptions::CookbookFrozen
|
108
|
-
ui.warn("Not updating version constraints for some cookbooks in the environment as the cookbook is frozen.")
|
109
|
-
end
|
110
|
-
ui.info("Uploaded all cookbooks.")
|
111
|
-
else
|
112
|
-
cookbook_path = config[:cookbook_path].respond_to?(:join) ? config[:cookbook_path].join(", ") : config[:cookbook_path]
|
113
|
-
ui.warn("Could not find any cookbooks in your cookbook path: #{cookbook_path}. Use --cookbook-path to specify the desired path.")
|
99
|
+
|
100
|
+
cookbooks = []
|
101
|
+
cookbooks_to_upload.each do |cookbook_name, cookbook|
|
102
|
+
raise Chef::Exceptions::MetadataNotFound.new(cookbook.root_paths[0], cookbook_name) unless cookbook.has_metadata_file?
|
103
|
+
|
104
|
+
if cookbook.metadata.name.nil?
|
105
|
+
message = "Cookbook loaded at path [#{cookbook.root_paths[0]}] has invalid metadata: #{cookbook.metadata.errors.join("; ")}"
|
106
|
+
raise Chef::Exceptions::MetadataNotValid, message
|
114
107
|
end
|
108
|
+
|
109
|
+
cookbooks << cookbook
|
110
|
+
end
|
111
|
+
|
112
|
+
if cookbooks.empty?
|
113
|
+
cookbook_path = config[:cookbook_path].respond_to?(:join) ? config[:cookbook_path].join(", ") : config[:cookbook_path]
|
114
|
+
ui.warn("Could not find any cookbooks in your cookbook path: #{cookbook_path}. Use --cookbook-path to specify the desired path.")
|
115
115
|
else
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
116
|
+
begin
|
117
|
+
tmp_cl = Chef::CookbookLoader.copy_to_tmp_dir_from_array(cookbooks)
|
118
|
+
tmp_cl.load_cookbooks
|
119
|
+
tmp_cl.compile_metadata
|
120
|
+
tmp_cl.freeze_versions if config[:freeze]
|
121
|
+
|
122
|
+
cookbooks_for_upload = []
|
123
|
+
tmp_cl.each do |cookbook_name, cookbook|
|
124
|
+
cookbooks_for_upload << cookbook
|
121
125
|
version_constraints_to_update[cookbook_name] = cookbook.version
|
122
|
-
rescue Exceptions::CookbookNotFoundInRepo => e
|
123
|
-
upload_failures += 1
|
124
|
-
ui.error("Could not find cookbook #{cookbook_name} in your cookbook path, skipping it")
|
125
|
-
Log.debug(e)
|
126
|
-
upload_failures += 1
|
127
|
-
rescue Exceptions::CookbookFrozen
|
128
|
-
ui.warn("Not updating version constraints for #{cookbook_name} in the environment as the cookbook is frozen.")
|
129
|
-
upload_failures += 1
|
130
126
|
end
|
131
|
-
|
127
|
+
if config[:all]
|
128
|
+
if cookbooks_for_upload.any?
|
129
|
+
begin
|
130
|
+
upload(cookbooks_for_upload, justify_width)
|
131
|
+
rescue Chef::Exceptions::CookbookFrozen
|
132
|
+
ui.warn("Not updating version constraints for some cookbooks in the environment as the cookbook is frozen.")
|
133
|
+
ui.error("Uploading of some of the cookbooks must be failed. Remove cookbook whose version is frozen from your cookbooks repo OR use --force option.")
|
134
|
+
upload_failures += 1
|
135
|
+
rescue SystemExit => e
|
136
|
+
tmp_cl.unlink!
|
137
|
+
raise exit e.status
|
138
|
+
end
|
139
|
+
ui.info("Uploaded all cookbooks.") if upload_failures == 0
|
140
|
+
end
|
141
|
+
else
|
142
|
+
tmp_cl.each do |cookbook_name, cookbook|
|
143
|
+
begin
|
144
|
+
upload([cookbook], justify_width)
|
145
|
+
upload_ok += 1
|
146
|
+
rescue Exceptions::CookbookNotFoundInRepo => e
|
147
|
+
upload_failures += 1
|
148
|
+
ui.error("Could not find cookbook #{cookbook_name} in your cookbook path, skipping it")
|
149
|
+
Log.debug(e)
|
150
|
+
upload_failures += 1
|
151
|
+
rescue Exceptions::CookbookFrozen
|
152
|
+
ui.warn("Not updating version constraints for #{cookbook_name} in the environment as the cookbook is frozen.")
|
153
|
+
upload_failures += 1
|
154
|
+
rescue SystemExit => e
|
155
|
+
tmp_cl.unlink!
|
156
|
+
raise exit e.status
|
157
|
+
end
|
158
|
+
end
|
132
159
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
160
|
+
if upload_failures == 0
|
161
|
+
ui.info "Uploaded #{upload_ok} cookbook#{upload_ok == 1 ? "" : "s"}."
|
162
|
+
elsif upload_failures > 0 && upload_ok > 0
|
163
|
+
ui.warn "Uploaded #{upload_ok} cookbook#{upload_ok == 1 ? "" : "s"} ok but #{upload_failures} " +
|
164
|
+
"cookbook#{upload_failures == 1 ? "" : "s"} upload failed."
|
165
|
+
elsif upload_failures > 0 && upload_ok == 0
|
166
|
+
ui.error "Failed to upload #{upload_failures} cookbook#{upload_failures == 1 ? "" : "s"}."
|
167
|
+
exit 1
|
168
|
+
end
|
169
|
+
end
|
170
|
+
unless version_constraints_to_update.empty?
|
171
|
+
update_version_constraints(version_constraints_to_update) if config[:environment]
|
172
|
+
end
|
173
|
+
ensure
|
174
|
+
tmp_cl.unlink!
|
141
175
|
end
|
142
176
|
end
|
143
|
-
|
144
|
-
unless version_constraints_to_update.empty?
|
145
|
-
update_version_constraints(version_constraints_to_update) if config[:environment]
|
146
|
-
end
|
147
177
|
end
|
148
178
|
|
149
179
|
def cookbooks_to_upload
|
@@ -161,7 +191,7 @@ class Chef
|
|
161
191
|
end
|
162
192
|
end
|
163
193
|
rescue Exceptions::CookbookNotFoundInRepo => e
|
164
|
-
ui.error(
|
194
|
+
ui.error(e.message)
|
165
195
|
Log.debug(e)
|
166
196
|
end
|
167
197
|
end
|