chef 12.17.44 → 12.18.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +3 -2
- data/Rakefile +9 -0
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +17 -17
- data/distro/common/html/knife_environment.html +4 -8
- data/distro/common/man/man1/knife-environment.1 +4 -16
- data/distro/powershell/chef/chef.psm1 +139 -24
- data/lib/chef/application.rb +5 -4
- data/lib/chef/application/windows_service_manager.rb +6 -4
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +8 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/data_collector.rb +24 -13
- data/lib/chef/data_collector/messages.rb +8 -6
- data/lib/chef/data_collector/messages/helpers.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/platform_introspection.rb +2 -2
- data/lib/chef/encrypted_data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +2 -2
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +5 -5
- data/lib/chef/file_access_control/unix.rb +5 -5
- data/lib/chef/formatters/error_description.rb +1 -1
- data/lib/chef/http/basic_client.rb +1 -1
- data/lib/chef/http/json_input.rb +2 -2
- data/lib/chef/knife.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/mixin/command.rb +1 -0
- data/lib/chef/mixin/deep_merge.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +58 -3
- data/lib/chef/mixin/which.rb +5 -9
- data/lib/chef/mixin/wide_string.rb +1 -1
- data/lib/chef/node.rb +1 -1
- data/lib/chef/node/attribute.rb +4 -5
- data/lib/chef/node_map.rb +18 -2
- data/lib/chef/platform/provider_handler_map.rb +2 -2
- data/lib/chef/platform/provider_mapping.rb +5 -0
- data/lib/chef/platform/resource_handler_map.rb +2 -2
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/git.rb +1 -1
- data/lib/chef/provider/group.rb +41 -46
- data/lib/chef/provider/group/aix.rb +12 -19
- data/lib/chef/provider/group/dscl.rb +46 -43
- data/lib/chef/provider/group/gpasswd.rb +7 -7
- data/lib/chef/provider/group/groupadd.rb +29 -34
- data/lib/chef/provider/group/groupmod.rb +26 -31
- data/lib/chef/provider/group/pw.rb +28 -31
- data/lib/chef/provider/group/suse.rb +9 -9
- data/lib/chef/provider/group/usermod.rb +10 -11
- data/lib/chef/provider/group/windows.rb +18 -20
- data/lib/chef/provider/ifconfig.rb +52 -63
- data/lib/chef/provider/ifconfig/aix.rb +23 -28
- data/lib/chef/provider/ifconfig/debian.rb +23 -22
- data/lib/chef/provider/ifconfig/redhat.rb +12 -12
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +4 -2
- data/lib/chef/provider/package.rb +16 -7
- data/lib/chef/provider/package/chocolatey.rb +3 -1
- data/lib/chef/provider/package/dnf.rb +183 -0
- data/lib/chef/provider/package/dnf/dnf_helper.py +91 -0
- data/lib/chef/provider/package/dnf/python_helper.rb +120 -0
- data/lib/chef/provider/package/dnf/version.rb +56 -0
- data/lib/chef/provider/package/easy_install.rb +1 -1
- data/lib/chef/provider/package/freebsd/base.rb +1 -1
- data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
- data/lib/chef/provider/package/powershell.rb +3 -3
- data/lib/chef/provider/package/windows.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/route.rb +186 -184
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/insserv.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/support/yum_repo.erb +10 -3
- data/lib/chef/provider/user.rb +17 -20
- data/lib/chef/provider/user/aix.rb +23 -24
- data/lib/chef/provider/user/dscl.rb +56 -53
- data/lib/chef/provider/user/linux.rb +13 -16
- data/lib/chef/provider/user/pw.rb +26 -30
- data/lib/chef/provider/user/solaris.rb +11 -12
- data/lib/chef/provider/user/useradd.rb +20 -22
- data/lib/chef/provider/user/windows.rb +19 -22
- data/lib/chef/provider_resolver.rb +4 -2
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +7 -0
- data/lib/chef/resource/chocolatey_package.rb +1 -0
- data/lib/chef/resource/dnf_package.rb +64 -0
- data/lib/chef/resource/file/verification.rb +6 -4
- data/lib/chef/resource/yum_package.rb +18 -14
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/resource_reporter.rb +11 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/scan_access_control.rb +4 -4
- data/lib/chef/util/dsc/resource_store.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/memory.rb +1 -1
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/sid.rb +2 -2
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/repodata/313329137b55fd333b2dc66394a6661a2befa6cc535d8460d92a4a78a9c581f0-primary.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/31ac4db5d5ac593728fcc26aef82b7b93c4cc4dbec843786b1845b939b658553-other.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/4ac40fa3c6728c1401318e2e20a997436624e83dcf7a5f952b851ef422637773-filelists.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/66391e53f0510b98b3f0b79f40ba1048026d9a1ef20905d9c40ba6f5411f3243-primary.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/8b34697595fcc87928e12d24644dda9462c3857bd932861e28bc77ae1f31be16-filelists.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/b97cca3fe14bcf06c52be4449b6108f7731239ff221111dcce8aada5467f60dc-other.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/repomd.xml +55 -0
- data/spec/functional/resource/dnf_package_spec.rb +686 -0
- data/spec/functional/resource/dsc_script_spec.rb +1 -0
- data/spec/functional/resource/user/useradd_spec.rb +10 -1
- data/spec/integration/knife/chef_repo_path_spec.rb +2 -2
- data/spec/integration/recipes/recipe_dsl_spec.rb +3 -0
- data/spec/integration/recipes/resource_load_spec.rb +3 -3
- data/spec/spec_helper.rb +5 -3
- data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
- data/spec/support/lib/chef/resource/cat.rb +1 -0
- data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -0
- data/spec/support/lib/chef/resource/openldap_includer.rb +2 -0
- data/spec/support/lib/chef/resource/with_state.rb +2 -0
- data/spec/support/lib/chef/resource/zen_master.rb +1 -0
- data/spec/unit/cookbook/metadata_spec.rb +3 -3
- data/spec/unit/data_collector/messages/helpers_spec.rb +7 -0
- data/spec/unit/data_collector_spec.rb +56 -0
- data/spec/unit/decorator/lazy_spec.rb +1 -1
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +3 -4
- data/spec/unit/node_spec.rb +23 -2
- data/spec/unit/platform_spec.rb +1 -0
- data/spec/unit/provider/group/dscl_spec.rb +29 -29
- data/spec/unit/provider/group/gpasswd_spec.rb +10 -10
- data/spec/unit/provider/group/groupadd_spec.rb +31 -30
- data/spec/unit/provider/group/groupmod_spec.rb +16 -16
- data/spec/unit/provider/group/pw_spec.rb +11 -11
- data/spec/unit/provider/group/suse_spec.rb +5 -5
- data/spec/unit/provider/group/usermod_spec.rb +15 -15
- data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
- data/spec/unit/provider/ifconfig/debian_spec.rb +10 -22
- data/spec/unit/provider/ifconfig/redhat_spec.rb +4 -4
- data/spec/unit/provider/ifconfig_spec.rb +18 -19
- data/spec/unit/provider/package/chocolatey_spec.rb +21 -21
- data/spec/unit/provider/package/msu_spec.rb +1 -1
- data/spec/unit/provider/route_spec.rb +21 -21
- data/spec/unit/provider/user/dscl_spec.rb +54 -57
- data/spec/unit/provider/user/linux_spec.rb +5 -5
- data/spec/unit/provider/user/pw_spec.rb +26 -22
- data/spec/unit/provider/user/windows_spec.rb +4 -4
- data/spec/unit/provider/user_spec.rb +19 -21
- data/spec/unit/provider_resolver_spec.rb +1 -0
- data/spec/unit/resource/chocolatey_package_spec.rb +12 -0
- data/spec/unit/resource/dnf_package_spec.rb +99 -0
- data/spec/unit/resource/remote_file_spec.rb +2 -2
- data/spec/unit/resource/yum_package_spec.rb +20 -0
- data/spec/unit/resource_reporter_spec.rb +24 -0
- data/spec/unit/resource_spec.rb +2 -0
- data/spec/unit/runner_spec.rb +1 -0
- data/tasks/bin/bundle-platform +1 -1
- data/tasks/gemfile_util.rb +2 -2
- data/tasks/templates/prerelease.md.erb +1 -10
- data/tasks/templates/release.md.erb +1 -9
- metadata +24 -5
- data/lib/chef/platform/handler_map.rb +0 -40
data/lib/chef/application.rb
CHANGED
@@ -120,9 +120,10 @@ class Chef
|
|
120
120
|
end
|
121
121
|
|
122
122
|
def set_specific_recipes
|
123
|
-
|
124
|
-
|
125
|
-
|
123
|
+
if cli_arguments.respond_to?(:map)
|
124
|
+
Chef::Config[:specific_recipes] =
|
125
|
+
cli_arguments.map { |file| File.expand_path(file) }
|
126
|
+
end
|
126
127
|
end
|
127
128
|
|
128
129
|
# Initialize and configure the logger.
|
@@ -342,7 +343,7 @@ class Chef
|
|
342
343
|
message = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
|
343
344
|
|
344
345
|
cause = e.cause if e.respond_to?(:cause)
|
345
|
-
|
346
|
+
until cause.nil?
|
346
347
|
message << "\n\n>>>> Caused by #{cause.class}: #{cause}\n#{cause.backtrace.join("\n")}"
|
347
348
|
cause = cause.respond_to?(:cause) ? cause.cause : nil
|
348
349
|
end
|
@@ -126,10 +126,12 @@ class Chef
|
|
126
126
|
:password => @password,
|
127
127
|
:dependencies => @dependencies
|
128
128
|
)
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
129
|
+
unless @delayed_start.nil?
|
130
|
+
::Win32::Service.configure(
|
131
|
+
:service_name => @service_name,
|
132
|
+
:delayed_start => @delayed_start
|
133
|
+
)
|
134
|
+
end
|
133
135
|
puts "Service '#{@service_name}' has successfully been installed."
|
134
136
|
end
|
135
137
|
when "status"
|
@@ -229,7 +229,7 @@ class Chef
|
|
229
229
|
end
|
230
230
|
end
|
231
231
|
|
232
|
-
if old_value == :none || (old_value
|
232
|
+
if old_value == :none || (old_value.nil? && !old_entry.exists?)
|
233
233
|
return [ [ :added, old_entry, new_entry, old_value, new_value ] ]
|
234
234
|
elsif new_value == :none
|
235
235
|
return [ [ :deleted, old_entry, new_entry, old_value, new_value ] ]
|
@@ -69,7 +69,14 @@ class Chef
|
|
69
69
|
def exists?
|
70
70
|
if @exists.nil?
|
71
71
|
begin
|
72
|
-
|
72
|
+
rest.get(api_path)
|
73
|
+
@exists = true
|
74
|
+
rescue Net::HTTPServerException => e
|
75
|
+
if e.response.code == "404"
|
76
|
+
@exists = false
|
77
|
+
else
|
78
|
+
raise
|
79
|
+
end
|
73
80
|
rescue Chef::ChefFS::FileSystem::NotFoundError
|
74
81
|
@exists = false
|
75
82
|
end
|
@@ -113,7 +113,7 @@ class Chef
|
|
113
113
|
Dir.mkdir(path, 0700)
|
114
114
|
if Chef::Platform.windows?
|
115
115
|
all_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_ALL
|
116
|
-
owner = Chef::ReservedNames::Win32::Security::SID.
|
116
|
+
owner = Chef::ReservedNames::Win32::Security::SID.default_security_object_owner
|
117
117
|
dacl = Chef::ReservedNames::Win32::Security::ACL.create([
|
118
118
|
Chef::ReservedNames::Win32::Security::ACE.access_allowed(owner, all_mask),
|
119
119
|
])
|
@@ -38,7 +38,7 @@ class Chef
|
|
38
38
|
if Chef::Platform.windows?
|
39
39
|
read_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_READ
|
40
40
|
write_mask = Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE
|
41
|
-
owner = Chef::ReservedNames::Win32::Security::SID.
|
41
|
+
owner = Chef::ReservedNames::Win32::Security::SID.default_security_object_owner
|
42
42
|
dacl = Chef::ReservedNames::Win32::Security::ACL.create([
|
43
43
|
Chef::ReservedNames::Win32::Security::ACE.access_allowed(owner, read_mask),
|
44
44
|
Chef::ReservedNames::Win32::Security::ACE.access_allowed(owner, write_mask),
|
@@ -52,7 +52,7 @@ class Chef
|
|
52
52
|
ignore_globs << line.strip unless line =~ COMMENTS_AND_WHITESPACE
|
53
53
|
end
|
54
54
|
else
|
55
|
-
Chef::Log.debug("No chefignore file found at
|
55
|
+
Chef::Log.debug("No chefignore file found at #{@ignore_file} no files will be ignored")
|
56
56
|
end
|
57
57
|
ignore_globs
|
58
58
|
end
|
@@ -308,7 +308,7 @@ class Chef
|
|
308
308
|
begin
|
309
309
|
@metadata.from_file(file)
|
310
310
|
rescue Chef::Exceptions::JSON::ParseError
|
311
|
-
Chef::Log.error("Error evaluating metadata.rb for
|
311
|
+
Chef::Log.error("Error evaluating metadata.rb for #{@inferred_cookbook_name} in " + file)
|
312
312
|
raise
|
313
313
|
end
|
314
314
|
end
|
@@ -317,7 +317,7 @@ class Chef
|
|
317
317
|
begin
|
318
318
|
@metadata.from_json(IO.read(file))
|
319
319
|
rescue Chef::Exceptions::JSON::ParseError
|
320
|
-
Chef::Log.error("Couldn't parse cookbook metadata JSON for
|
320
|
+
Chef::Log.error("Couldn't parse cookbook metadata JSON for #{@inferred_cookbook_name} in " + file)
|
321
321
|
raise
|
322
322
|
end
|
323
323
|
end
|
@@ -336,7 +336,7 @@ class Chef
|
|
336
336
|
# metadata contains a name key.
|
337
337
|
@metadata.name(data["cookbook_name"]) unless data["metadata"].key?("name")
|
338
338
|
rescue Chef::Exceptions::JSON::ParseError
|
339
|
-
Chef::Log.error("Couldn't parse cookbook metadata JSON for
|
339
|
+
Chef::Log.error("Couldn't parse cookbook metadata JSON for #{@inferred_cookbook_name} in " + file)
|
340
340
|
raise
|
341
341
|
end
|
342
342
|
end
|
@@ -347,7 +347,7 @@ class Chef
|
|
347
347
|
data = Chef::JSONCompat.parse(IO.read(uploaded_cookbook_version_file))
|
348
348
|
@frozen = data["frozen?"]
|
349
349
|
rescue Chef::Exceptions::JSON::ParseError
|
350
|
-
Chef::Log.error("Couldn't parse cookbook metadata JSON for
|
350
|
+
Chef::Log.error("Couldn't parse cookbook metadata JSON for #{@inferred_cookbook_name} in #{uploaded_cookbook_version_file}")
|
351
351
|
raise
|
352
352
|
end
|
353
353
|
end
|
@@ -862,12 +862,12 @@ INVALID
|
|
862
862
|
return if !options[:choice].is_a?(Array) || options[:choice].empty?
|
863
863
|
|
864
864
|
if options[:default].is_a?(String) && options[:default] != ""
|
865
|
-
raise ArgumentError, "Default must be one of your choice values!" if options[:choice].index(options[:default])
|
865
|
+
raise ArgumentError, "Default must be one of your choice values!" if options[:choice].index(options[:default]).nil?
|
866
866
|
end
|
867
867
|
|
868
868
|
if options[:default].is_a?(Array) && !options[:default].empty?
|
869
869
|
options[:default].each do |val|
|
870
|
-
raise ArgumentError, "Default values must be a subset of your choice values!" if options[:choice].index(val)
|
870
|
+
raise ArgumentError, "Default values must be a subset of your choice values!" if options[:choice].index(val).nil?
|
871
871
|
end
|
872
872
|
end
|
873
873
|
end
|
data/lib/chef/cookbook_loader.rb
CHANGED
data/lib/chef/data_collector.rb
CHANGED
@@ -430,26 +430,33 @@ class Chef
|
|
430
430
|
end
|
431
431
|
|
432
432
|
def detect_unprocessed_resources
|
433
|
-
# create a
|
434
|
-
# the Resource Collection
|
435
|
-
|
433
|
+
# create a Hash (for performance reasons, rather than an Array) containing all
|
434
|
+
# resource+action combinations from the Resource Collection
|
435
|
+
#
|
436
|
+
# We use the object ID instead of the resource itself in the Hash key because
|
437
|
+
# we currently allow users to create a property called "hash" which creates
|
438
|
+
# a #hash instance method on the resource. Ruby expects that to be a Fixnum,
|
439
|
+
# so bad things happen when adding an object to an Array or a Hash if it's not.
|
440
|
+
collection_resources = {}
|
436
441
|
run_context.resource_collection.all_resources.each do |resource|
|
437
442
|
Array(resource.action).each do |action|
|
438
|
-
collection_resources
|
443
|
+
collection_resources[[resource.__id__, action]] = resource
|
439
444
|
end
|
440
445
|
end
|
441
446
|
|
442
|
-
# Delete from the
|
447
|
+
# Delete from the Hash any resource+action combination we have
|
443
448
|
# already processed.
|
444
449
|
all_resource_reports.each do |report|
|
445
|
-
collection_resources.delete([report.resource, report.action])
|
450
|
+
collection_resources.delete([report.resource.__id__, report.action])
|
446
451
|
end
|
447
452
|
|
448
|
-
# The items remaining in the
|
453
|
+
# The items remaining in the Hash are unprocessed resource+actions,
|
449
454
|
# so we'll create new resource reports for them which default to
|
450
455
|
# a state of "unprocessed".
|
451
|
-
collection_resources.each do |
|
452
|
-
|
456
|
+
collection_resources.each do |key, resource|
|
457
|
+
# The Hash key is an array of the Resource's object ID and the action.
|
458
|
+
# We need to pluck out the action.
|
459
|
+
add_resource_report(create_resource_report(resource, key[1]))
|
453
460
|
end
|
454
461
|
end
|
455
462
|
|
@@ -462,8 +469,10 @@ class Chef
|
|
462
469
|
end
|
463
470
|
|
464
471
|
def validate_data_collector_server_url!
|
465
|
-
|
466
|
-
|
472
|
+
if data_collector_server_url.empty?
|
473
|
+
raise Chef::Exceptions::ConfigurationError,
|
474
|
+
"Chef::Config[:data_collector][:server_url] is empty. Please supply a valid URL."
|
475
|
+
end
|
467
476
|
|
468
477
|
begin
|
469
478
|
uri = URI(data_collector_server_url)
|
@@ -471,8 +480,10 @@ class Chef
|
|
471
480
|
raise Chef::Exceptions::ConfigurationError, "Chef::Config[:data_collector][:server_url] (#{data_collector_server_url}) is not a valid URI."
|
472
481
|
end
|
473
482
|
|
474
|
-
|
475
|
-
|
483
|
+
if uri.host.nil?
|
484
|
+
raise Chef::Exceptions::ConfigurationError,
|
485
|
+
"Chef::Config[:data_collector][:server_url] (#{data_collector_server_url}) is a URI with no host. Please supply a valid URL."
|
486
|
+
end
|
476
487
|
end
|
477
488
|
end
|
478
489
|
end
|
@@ -82,12 +82,14 @@ class Chef
|
|
82
82
|
"deprecations" => reporter_data[:deprecations],
|
83
83
|
}
|
84
84
|
|
85
|
-
|
86
|
-
"
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
if run_status.exception
|
86
|
+
message["error"] = {
|
87
|
+
"class" => run_status.exception.class,
|
88
|
+
"message" => run_status.exception.message,
|
89
|
+
"backtrace" => run_status.exception.backtrace,
|
90
|
+
"description" => reporter_data[:error_descriptions],
|
91
|
+
}
|
92
|
+
end
|
91
93
|
|
92
94
|
message
|
93
95
|
end
|
@@ -76,7 +76,7 @@ class Chef
|
|
76
76
|
def chef_server_organization
|
77
77
|
return "unknown_organization" unless Chef::Config[:chef_server_url]
|
78
78
|
|
79
|
-
Chef::Config[:chef_server_url].match(%r{/+organizations/+(
|
79
|
+
Chef::Config[:chef_server_url].match(%r{/+organizations/+([a-z0-9][a-z0-9_-]{0,254})}).nil? ? "unknown_organization" : $1
|
80
80
|
end
|
81
81
|
|
82
82
|
#
|
data/lib/chef/deprecated.rb
CHANGED
@@ -156,6 +156,26 @@ class Chef
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
class ChefPlatformMethods < Base
|
160
|
+
def id
|
161
|
+
13
|
162
|
+
end
|
163
|
+
|
164
|
+
def target
|
165
|
+
"chef_platform_methods.html"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
class RunCommand < Base
|
170
|
+
def id
|
171
|
+
14
|
172
|
+
end
|
173
|
+
|
174
|
+
def target
|
175
|
+
"run_command.html"
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
159
179
|
class ResourceCloning < Base
|
160
180
|
def id
|
161
181
|
3694
|
@@ -176,6 +196,16 @@ class Chef
|
|
176
196
|
end
|
177
197
|
end
|
178
198
|
|
199
|
+
class DnfPackageAllowDowngrade < Base
|
200
|
+
def id
|
201
|
+
10
|
202
|
+
end
|
203
|
+
|
204
|
+
def target
|
205
|
+
"dnf_package_allow_downgrade.html"
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
179
209
|
class Generic < Base
|
180
210
|
def url
|
181
211
|
"https://docs.chef.io/chef_deprecations_client.html"
|
@@ -257,8 +257,8 @@ class Chef
|
|
257
257
|
def docker?(node = run_context.nil? ? nil : run_context.node)
|
258
258
|
# Using "File.exist?('/.dockerinit') || File.exist?('/.dockerenv')" makes Travis sad,
|
259
259
|
# and that makes us sad too.
|
260
|
-
node && node[:virtualization] && node[:virtualization][:systems] &&
|
261
|
-
|
260
|
+
!!(node && node[:virtualization] && node[:virtualization][:systems] &&
|
261
|
+
node[:virtualization][:systems][:docker] && node[:virtualization][:systems][:docker] == "guest")
|
262
262
|
end
|
263
263
|
|
264
264
|
end
|
@@ -121,7 +121,7 @@ class Chef::EncryptedDataBagItem
|
|
121
121
|
#
|
122
122
|
def self.load(data_bag, name, secret = nil)
|
123
123
|
raw_hash = Chef::DataBagItem.load(data_bag, name)
|
124
|
-
secret
|
124
|
+
secret ||= self.load_secret
|
125
125
|
self.new(raw_hash, secret)
|
126
126
|
end
|
127
127
|
|
@@ -93,7 +93,7 @@ class Chef::EncryptedDataBagItem
|
|
93
93
|
plaintext << openssl_decryptor.final
|
94
94
|
rescue OpenSSL::Cipher::CipherError => e
|
95
95
|
# if the key length is less than 255 characters, and it contains slashes, we think it may be a path.
|
96
|
-
raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{
|
96
|
+
raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{(@key.length < 255 && @key.include?('/')) ? 'You may need to use --secret-file rather than --secret.' : ''}"
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -144,7 +144,7 @@ class Chef::EncryptedDataBagItem
|
|
144
144
|
plaintext << openssl_decryptor.final
|
145
145
|
rescue OpenSSL::Cipher::CipherError => e
|
146
146
|
# if the key length is less than 255 characters, and it contains slashes, we think it may be a path.
|
147
|
-
raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{
|
147
|
+
raise DecryptionFailure, "Error decrypting data bag value: '#{e.message}'. Most likely the provided key is incorrect. #{( @key.length < 255 && @key.include?('/')) ? 'You may need to use --secret-file rather than --secret.' : ''}"
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
data/lib/chef/environment.rb
CHANGED
@@ -171,7 +171,7 @@ class Chef
|
|
171
171
|
unless params[:cookbook_version].nil?
|
172
172
|
params[:cookbook_version].each do |index, cookbook_constraint_spec|
|
173
173
|
unless cookbook_constraint_spec.nil? || cookbook_constraint_spec.size == 0
|
174
|
-
valid
|
174
|
+
valid &&= update_cookbook_constraint_from_param(index, cookbook_constraint_spec)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
data/lib/chef/exceptions.rb
CHANGED
@@ -76,10 +76,10 @@ class Chef
|
|
76
76
|
class Group < RuntimeError; end
|
77
77
|
class Link < RuntimeError; end
|
78
78
|
class Mount < RuntimeError; end
|
79
|
-
class Reboot < Exception; end
|
80
|
-
class RebootPending < Exception; end
|
79
|
+
class Reboot < Exception; end # rubocop:disable Lint/InheritException
|
80
|
+
class RebootPending < Exception; end # rubocop:disable Lint/InheritException
|
81
81
|
class RebootFailed < Mixlib::ShellOut::ShellCommandFailed; end
|
82
|
-
class ClientUpgraded < Exception; end
|
82
|
+
class ClientUpgraded < Exception; end # rubocop:disable Lint/InheritException
|
83
83
|
class PrivateKeyMissing < RuntimeError; end
|
84
84
|
class CannotWritePrivateKey < RuntimeError; end
|
85
85
|
class RoleNotFound < RuntimeError; end
|
@@ -159,7 +159,7 @@ class Chef
|
|
159
159
|
|
160
160
|
# Thrown when Win32 API layer binds to non-existent Win32 function. Occurs
|
161
161
|
# when older versions of Windows don't support newer Win32 API functions.
|
162
|
-
class Win32APIFunctionNotImplemented < NotImplementedError; end
|
162
|
+
class Win32APIFunctionNotImplemented < NotImplementedError; end # rubocop:disable Lint/InheritException
|
163
163
|
# Attempting to run windows code on a not-windows node
|
164
164
|
class Win32NotWindows < RuntimeError; end
|
165
165
|
class WindowsNotAdmin < RuntimeError; end
|
@@ -196,7 +196,7 @@ class Chef
|
|
196
196
|
class InvalidVersionConstraint < ArgumentError; end
|
197
197
|
|
198
198
|
# Version constraints are not allowed in chef-solo
|
199
|
-
class IllegalVersionConstraint < NotImplementedError; end
|
199
|
+
class IllegalVersionConstraint < NotImplementedError; end # rubocop:disable Lint/InheritException
|
200
200
|
|
201
201
|
class MetadataNotValid < StandardError; end
|
202
202
|
class MetadataNotFound < StandardError
|
@@ -117,13 +117,13 @@ class Chef
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def gid_from_resource(resource)
|
120
|
-
return nil if resource
|
120
|
+
return nil if resource.nil? || resource.group.nil?
|
121
121
|
if resource.group.kind_of?(String)
|
122
122
|
diminished_radix_complement( Etc.getgrnam(resource.group).gid )
|
123
123
|
elsif resource.group.kind_of?(Integer)
|
124
124
|
resource.group
|
125
125
|
else
|
126
|
-
Chef::Log.error("The `group` parameter of the
|
126
|
+
Chef::Log.error("The `group` parameter of the #{@resource} resource is set to an invalid value (#{resource.owner.inspect})")
|
127
127
|
raise ArgumentError, "cannot resolve #{resource.group.inspect} to gid, group must be a string or integer"
|
128
128
|
end
|
129
129
|
rescue ArgumentError
|
@@ -168,7 +168,7 @@ class Chef
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def mode_from_resource(res)
|
171
|
-
return nil if res
|
171
|
+
return nil if res.nil? || res.mode.nil?
|
172
172
|
(res.mode.respond_to?(:oct) ? res.mode.oct : res.mode.to_i) & 007777
|
173
173
|
end
|
174
174
|
|
@@ -264,13 +264,13 @@ class Chef
|
|
264
264
|
end
|
265
265
|
|
266
266
|
def uid_from_resource(resource)
|
267
|
-
return nil if resource
|
267
|
+
return nil if resource.nil? || resource.owner.nil?
|
268
268
|
if resource.owner.kind_of?(String)
|
269
269
|
diminished_radix_complement( Etc.getpwnam(resource.owner).uid )
|
270
270
|
elsif resource.owner.kind_of?(Integer)
|
271
271
|
resource.owner
|
272
272
|
else
|
273
|
-
Chef::Log.error("The `owner` parameter of the
|
273
|
+
Chef::Log.error("The `owner` parameter of the #{@resource} resource is set to an invalid value (#{resource.owner.inspect})")
|
274
274
|
raise ArgumentError, "cannot resolve #{resource.owner.inspect} to uid, owner must be a string or integer"
|
275
275
|
end
|
276
276
|
rescue ArgumentError
|
@@ -111,7 +111,7 @@ class Chef
|
|
111
111
|
# match no_proxy with a fuzzy matcher, rather than letting Net::HTTP
|
112
112
|
# do it.
|
113
113
|
http_client = http_client_builder.new(host, port, nil)
|
114
|
-
http_client.proxy_port = nil if http_client.proxy_address
|
114
|
+
http_client.proxy_port = nil if http_client.proxy_address.nil?
|
115
115
|
|
116
116
|
if url.scheme == HTTPS
|
117
117
|
configure_ssl(http_client)
|