chef 16.3.45-universal-mingw32 → 16.4.35-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/chef-universal-mingw32.gemspec +0 -1
- data/lib/chef/action_collection.rb +4 -0
- data/lib/chef/api_client/registration.rb +2 -2
- data/lib/chef/application.rb +1 -1
- data/lib/chef/application/apply.rb +5 -5
- data/lib/chef/application/windows_service.rb +27 -27
- data/lib/chef/chef_class.rb +0 -1
- data/lib/chef/chef_fs/chef_fs_data_store.rb +54 -54
- data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +10 -10
- data/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb +8 -8
- data/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb +8 -8
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +18 -18
- data/lib/chef/chef_fs/file_system/repository/directory.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +1 -1
- data/lib/chef/client.rb +11 -11
- data/lib/chef/data_collector/run_end_message.rb +11 -1
- data/lib/chef/dsl/platform_introspection.rb +8 -8
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +1 -1
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/exceptions.rb +1 -1
- data/lib/chef/file_content_management/tempfile.rb +9 -9
- data/lib/chef/http.rb +2 -1
- data/lib/chef/json_compat.rb +1 -1
- data/lib/chef/knife/bootstrap.rb +2 -2
- data/lib/chef/knife/cookbook_download.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +1 -1
- data/lib/chef/knife/cookbook_upload.rb +23 -23
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/hashed_command_loader.rb +2 -2
- data/lib/chef/knife/core/windows_bootstrap_context.rb +32 -24
- data/lib/chef/knife/delete.rb +15 -15
- data/lib/chef/knife/exec.rb +2 -2
- data/lib/chef/knife/ssh.rb +6 -6
- data/lib/chef/knife/xargs.rb +19 -19
- data/lib/chef/knife/yaml_convert.rb +1 -1
- data/lib/chef/mixin/checksum.rb +0 -1
- data/lib/chef/mixin/deep_merge.rb +35 -6
- data/lib/chef/mixin/openssl_helper.rb +3 -1
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/mixin/which.rb +1 -1
- data/lib/chef/monkey_patches/webrick-utils.rb +10 -10
- data/lib/chef/node/attribute.rb +2 -4
- data/lib/chef/platform/service_helpers.rb +1 -1
- data/lib/chef/property.rb +1 -1
- data/lib/chef/provider/cron/unix.rb +0 -2
- data/lib/chef/provider/git.rb +5 -5
- data/lib/chef/provider/group.rb +0 -2
- data/lib/chef/provider/group/suse.rb +5 -5
- data/lib/chef/provider/ifconfig.rb +1 -4
- data/lib/chef/provider/mount.rb +0 -2
- data/lib/chef/provider/package.rb +0 -2
- data/lib/chef/provider/package/rubygems.rb +1 -1
- data/lib/chef/provider/package/snap.rb +1 -1
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +9 -9
- data/lib/chef/provider/powershell_script.rb +21 -5
- data/lib/chef/provider/route.rb +1 -1
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/openbsd.rb +1 -4
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/service/windows.rb +10 -10
- data/lib/chef/provider/systemd_unit.rb +0 -2
- data/lib/chef/provider/template/content.rb +1 -0
- data/lib/chef/provider/user/dscl.rb +2 -2
- data/lib/chef/provider/user/mac.rb +9 -9
- data/lib/chef/provider/windows_task.rb +0 -3
- data/lib/chef/provider/zypper_repository.rb +0 -1
- data/lib/chef/providers.rb +0 -1
- data/lib/chef/recipe.rb +1 -1
- data/lib/chef/resource.rb +6 -10
- data/lib/chef/resource/apt_repository.rb +1 -10
- data/lib/chef/resource/chef_client_systemd_timer.rb +2 -2
- data/lib/chef/resource/chef_vault_secret.rb +13 -13
- data/lib/chef/resource/execute.rb +2 -3
- data/lib/chef/resource/homebrew_update.rb +2 -2
- data/lib/chef/resource/openssl_dhparam.rb +2 -0
- data/lib/chef/resource/openssl_ec_private_key.rb +2 -0
- data/lib/chef/resource/openssl_ec_public_key.rb +2 -0
- data/lib/chef/resource/openssl_rsa_private_key.rb +2 -0
- data/lib/chef/resource/openssl_rsa_public_key.rb +2 -0
- data/lib/chef/resource/openssl_x509_certificate.rb +24 -21
- data/lib/chef/resource/openssl_x509_crl.rb +2 -0
- data/lib/chef/resource/openssl_x509_request.rb +23 -20
- data/lib/chef/resource/osx_profile.rb +227 -5
- data/lib/chef/resource/powershell_package_source.rb +1 -1
- data/lib/chef/resource/powershell_script.rb +24 -30
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/sysctl.rb +5 -5
- data/lib/chef/resource/windows_ad_join.rb +2 -0
- data/lib/chef/resource/windows_audit_policy.rb +3 -0
- data/lib/chef/resource/windows_auto_run.rb +2 -0
- data/lib/chef/resource/windows_certificate.rb +2 -0
- data/lib/chef/resource/windows_dfs_folder.rb +2 -0
- data/lib/chef/resource/windows_dfs_namespace.rb +2 -0
- data/lib/chef/resource/windows_dfs_server.rb +2 -0
- data/lib/chef/resource/windows_dns_record.rb +10 -7
- data/lib/chef/resource/windows_dns_zone.rb +12 -7
- data/lib/chef/resource/windows_feature.rb +2 -0
- data/lib/chef/resource/windows_feature_dism.rb +10 -0
- data/lib/chef/resource/windows_feature_powershell.rb +14 -2
- data/lib/chef/resource/windows_firewall_profile.rb +4 -2
- data/lib/chef/resource/windows_firewall_rule.rb +5 -3
- data/lib/chef/resource/windows_font.rb +3 -1
- data/lib/chef/resource/windows_pagefile.rb +4 -0
- data/lib/chef/resource/windows_printer.rb +17 -18
- data/lib/chef/resource/windows_printer_port.rb +14 -13
- data/lib/chef/resource/windows_security_policy.rb +2 -0
- data/lib/chef/resource/windows_share.rb +5 -3
- data/lib/chef/resource/windows_shortcut.rb +2 -0
- data/lib/chef/resource/windows_uac.rb +2 -0
- data/lib/chef/resource/windows_user_privilege.rb +2 -0
- data/lib/chef/resource/windows_workgroup.rb +2 -3
- data/lib/chef/resource_collection/stepable_iterator.rb +1 -2
- data/lib/chef/role.rb +2 -2
- data/lib/chef/run_context/cookbook_compiler.rb +20 -20
- data/lib/chef/run_status.rb +2 -6
- data/lib/chef/shell.rb +1 -1
- data/lib/chef/util/backup.rb +1 -1
- data/lib/chef/util/diff.rb +11 -11
- data/lib/chef/util/powershell/cmdlet.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/file.rb +2 -2
- data/lib/chef/win32/file/version_info.rb +5 -5
- data/spec/data/ssl/chef-rspec.cert +15 -15
- data/spec/functional/resource/aixinit_service_spec.rb +7 -7
- data/spec/functional/resource/bff_spec.rb +2 -2
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dsc_resource_spec.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +0 -1
- data/spec/functional/resource/group_spec.rb +6 -6
- data/spec/functional/resource/insserv_spec.rb +4 -4
- data/spec/functional/resource/link_spec.rb +20 -20
- data/spec/functional/resource/powershell_script_spec.rb +4 -4
- data/spec/functional/resource/rpm_spec.rb +2 -2
- data/spec/functional/resource/windows_certificate_spec.rb +3 -3
- data/spec/functional/resource/windows_font_spec.rb +49 -0
- data/spec/functional/resource/windows_security_policy_spec.rb +0 -3
- data/spec/functional/run_lock_spec.rb +24 -24
- data/spec/functional/win32/registry_spec.rb +8 -8
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/integration/knife/common_options_spec.rb +12 -12
- data/spec/integration/knife/config_get_profile_spec.rb +69 -68
- data/spec/integration/knife/config_get_spec.rb +126 -125
- data/spec/integration/knife/config_list_profiles_spec.rb +181 -180
- data/spec/integration/knife/config_use_profile_spec.rb +110 -109
- data/spec/integration/knife/diff_spec.rb +3 -1
- data/spec/integration/knife/download_spec.rb +3 -1
- data/spec/integration/knife/serve_spec.rb +5 -5
- data/spec/integration/knife/upload_spec.rb +3 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/spec_helper.rb +6 -6
- data/spec/support/platform_helpers.rb +9 -9
- data/spec/support/platforms/win32/spec_service.rb +1 -1
- data/spec/support/shared/functional/directory_resource.rb +1 -1
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +20 -20
- data/spec/support/shared/functional/win32_service.rb +1 -1
- data/spec/support/shared/functional/windows_script.rb +3 -3
- data/spec/support/shared/integration/integration_helper.rb +22 -52
- data/spec/support/shared/unit/script_resource.rb +6 -20
- data/spec/support/shared/unit/windows_script_resource.rb +15 -28
- data/spec/unit/data_collector_spec.rb +22 -0
- data/spec/unit/environment_spec.rb +7 -7
- data/spec/unit/knife/bootstrap_spec.rb +14 -14
- data/spec/unit/knife/cookbook_download_spec.rb +4 -4
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +1 -1
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
- data/spec/unit/knife/core/windows_bootstrap_context_spec.rb +21 -12
- data/spec/unit/knife/supermarket_share_spec.rb +1 -1
- data/spec/unit/mixin/template_spec.rb +30 -30
- data/spec/unit/mixin/windows_architecture_helper_spec.rb +4 -4
- data/spec/unit/node/immutable_collections_spec.rb +6 -2
- data/spec/unit/node_spec.rb +5 -5
- data/spec/unit/provider/powershell_script_spec.rb +11 -4
- data/spec/unit/provider/remote_directory_spec.rb +9 -9
- data/spec/unit/provider/service/arch_service_spec.rb +3 -2
- data/spec/unit/provider/service/debian_service_spec.rb +1 -1
- data/spec/unit/provider/service/gentoo_service_spec.rb +7 -7
- data/spec/unit/provider/service/macosx_spec.rb +3 -3
- data/spec/unit/provider/service/redhat_spec.rb +2 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +3 -3
- data/spec/unit/provider_resolver_spec.rb +6 -6
- data/spec/unit/resource/batch_spec.rb +6 -6
- data/spec/unit/resource/execute_spec.rb +113 -118
- data/spec/unit/resource/osx_profile_spec.rb +233 -0
- data/spec/unit/resource/powershell_script_spec.rb +11 -29
- data/spec/unit/resource/script_spec.rb +6 -1
- data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
- data/spec/unit/role_spec.rb +11 -11
- data/tasks/rspec.rb +1 -1
- metadata +7 -22
- data/lib/chef/provider/osx_profile.rb +0 -255
- data/spec/unit/provider/osx_profile_spec.rb +0 -255
data/lib/chef/client.rb
CHANGED
@@ -54,7 +54,7 @@ require_relative "platform/rebooter"
|
|
54
54
|
require_relative "mixin/deprecation"
|
55
55
|
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
56
56
|
require "ohai" unless defined?(Ohai::System)
|
57
|
-
require "rbconfig"
|
57
|
+
require "rbconfig" unless defined?(RbConfig)
|
58
58
|
require_relative "dist"
|
59
59
|
require "forwardable" unless defined?(Forwardable)
|
60
60
|
|
@@ -707,16 +707,16 @@ class Chef
|
|
707
707
|
#
|
708
708
|
def converge(run_context)
|
709
709
|
catch(:end_client_run_early) do
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
710
|
+
|
711
|
+
events.converge_start(run_context)
|
712
|
+
logger.debug("Converging node #{node_name}")
|
713
|
+
@runner = Chef::Runner.new(run_context)
|
714
|
+
@runner.converge
|
715
|
+
events.converge_complete
|
716
|
+
rescue Exception => e
|
717
|
+
events.converge_failed(e)
|
718
|
+
raise e
|
719
|
+
|
720
720
|
end
|
721
721
|
end
|
722
722
|
|
@@ -133,7 +133,17 @@ class Chef
|
|
133
133
|
end
|
134
134
|
|
135
135
|
hash["conditional"] = action_record.conditional.to_text if action_record.status == :skipped
|
136
|
-
|
136
|
+
|
137
|
+
unless action_record.exception.nil?
|
138
|
+
hash["error_message"] = action_record.exception.message
|
139
|
+
|
140
|
+
hash["error"] = {
|
141
|
+
"class" => action_record.exception.class,
|
142
|
+
"message" => action_record.exception.message,
|
143
|
+
"backtrace" => action_record.exception.backtrace,
|
144
|
+
"description" => action_record.error_description,
|
145
|
+
}
|
146
|
+
end
|
137
147
|
|
138
148
|
hash
|
139
149
|
end
|
@@ -17,7 +17,7 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
20
|
-
|
20
|
+
require_relative "../mixin/chef_utils_wiring" unless defined?(Chef::Mixin::ChefUtilsWiring)
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
module DSL
|
@@ -79,14 +79,14 @@ class Chef
|
|
79
79
|
key_matches = []
|
80
80
|
keys = @values[platform].keys
|
81
81
|
keys.each do |k|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
rescue Chef::Exceptions::InvalidVersionConstraint => e
|
87
|
-
Chef::Log.trace "Caught InvalidVersionConstraint. This means that a key in value_for_platform cannot be interpreted as a Chef::VersionConstraint::Platform."
|
88
|
-
Chef::Log.trace(e)
|
82
|
+
|
83
|
+
if Chef::VersionConstraint::Platform.new(k).include?(node_version)
|
84
|
+
key_matches << k
|
89
85
|
end
|
86
|
+
rescue Chef::Exceptions::InvalidVersionConstraint => e
|
87
|
+
Chef::Log.trace "Caught InvalidVersionConstraint. This means that a key in value_for_platform cannot be interpreted as a Chef::VersionConstraint::Platform."
|
88
|
+
Chef::Log.trace(e)
|
89
|
+
|
90
90
|
end
|
91
91
|
return @values[platform][version] if key_matches.include?(version)
|
92
92
|
|
data/lib/chef/environment.rb
CHANGED
@@ -254,11 +254,11 @@ class Chef
|
|
254
254
|
js_file = File.join(Chef::Config[:environment_path], "#{name}.json")
|
255
255
|
rb_file = File.join(Chef::Config[:environment_path], "#{name}.rb")
|
256
256
|
|
257
|
-
if File.
|
257
|
+
if File.exist?(js_file)
|
258
258
|
# from_json returns object.class => json_class in the JSON.
|
259
259
|
hash = Chef::JSONCompat.parse(IO.read(js_file))
|
260
260
|
from_hash(hash)
|
261
|
-
elsif File.
|
261
|
+
elsif File.exist?(rb_file)
|
262
262
|
environment = Chef::Environment.new
|
263
263
|
environment.name(name)
|
264
264
|
environment.from_file(rb_file)
|
data/lib/chef/exceptions.rb
CHANGED
@@ -423,7 +423,7 @@ class Chef
|
|
423
423
|
|
424
424
|
class ChecksumMismatch < RuntimeError
|
425
425
|
def initialize(res_cksum, cont_cksum)
|
426
|
-
super "Checksum on resource (#{res_cksum}) does not match checksum on content (#{cont_cksum})"
|
426
|
+
super "Checksum on resource (#{res_cksum}...) does not match checksum on content (#{cont_cksum}...)"
|
427
427
|
end
|
428
428
|
end
|
429
429
|
|
@@ -39,15 +39,15 @@ class Chef
|
|
39
39
|
errors = [ ]
|
40
40
|
|
41
41
|
tempfile_dirnames.each do |tempfile_dirname|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
42
|
+
|
43
|
+
# preserving the file extension of the target filename should be considered a public API
|
44
|
+
tf = ::Tempfile.open([tempfile_basename, tempfile_extension], tempfile_dirname)
|
45
|
+
break
|
46
|
+
rescue SystemCallError => e
|
47
|
+
message = "Creating temp file under '#{tempfile_dirname}' failed with: '#{e.message}'"
|
48
|
+
Chef::Log.trace(message)
|
49
|
+
errors << message
|
50
|
+
|
51
51
|
end
|
52
52
|
|
53
53
|
raise Chef::Exceptions::FileContentStagingError, errors if tf.nil?
|
data/lib/chef/http.rb
CHANGED
@@ -22,7 +22,8 @@
|
|
22
22
|
#
|
23
23
|
|
24
24
|
require "tempfile" unless defined?(Tempfile)
|
25
|
-
require "
|
25
|
+
require "openssl" unless defined?(OpenSSL)
|
26
|
+
require "net/http" unless defined?(Net::HTTP)
|
26
27
|
require "uri" unless defined?(URI)
|
27
28
|
require_relative "http/basic_client"
|
28
29
|
require_relative "monkey_patches/net_http"
|
data/lib/chef/json_compat.rb
CHANGED
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -480,7 +480,7 @@ class Chef
|
|
480
480
|
template = bootstrap_template
|
481
481
|
|
482
482
|
# Use the template directly if it's a path to an actual file
|
483
|
-
if File.
|
483
|
+
if File.exist?(template)
|
484
484
|
Chef::Log.trace("Using the specified bootstrap template: #{File.dirname(template)}")
|
485
485
|
return template
|
486
486
|
end
|
@@ -495,7 +495,7 @@ class Chef
|
|
495
495
|
|
496
496
|
template_file = Array(bootstrap_files).find do |bootstrap_template|
|
497
497
|
Chef::Log.trace("Looking for bootstrap template in #{File.dirname(bootstrap_template)}")
|
498
|
-
File.
|
498
|
+
File.exist?(bootstrap_template)
|
499
499
|
end
|
500
500
|
|
501
501
|
unless template_file
|
@@ -73,7 +73,7 @@ class Chef
|
|
73
73
|
manifest = cookbook.cookbook_manifest
|
74
74
|
|
75
75
|
basedir = File.join(config[:download_directory], "#{@cookbook_name}-#{cookbook.version}")
|
76
|
-
if File.
|
76
|
+
if File.exist?(basedir)
|
77
77
|
if config[:force]
|
78
78
|
Chef::Log.trace("Deleting #{basedir}")
|
79
79
|
FileUtils.rm_rf(basedir)
|
@@ -62,7 +62,7 @@ class Chef
|
|
62
62
|
def generate_metadata(cookbook)
|
63
63
|
Array(config[:cookbook_path]).reverse_each do |path|
|
64
64
|
file = File.expand_path(File.join(path, cookbook, "metadata.rb"))
|
65
|
-
if File.
|
65
|
+
if File.exist?(file)
|
66
66
|
generate_metadata_from_file(cookbook, file)
|
67
67
|
else
|
68
68
|
validate_metadata_json(path, cookbook)
|
@@ -132,20 +132,20 @@ class Chef
|
|
132
132
|
end
|
133
133
|
else
|
134
134
|
tmp_cl.each do |cookbook_name, cookbook|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
135
|
+
|
136
|
+
upload([cookbook], justify_width)
|
137
|
+
upload_ok += 1
|
138
|
+
rescue Exceptions::CookbookNotFoundInRepo => e
|
139
|
+
upload_failures += 1
|
140
|
+
ui.error("Could not find cookbook #{cookbook_name} in your cookbook path, skipping it")
|
141
|
+
Log.debug(e)
|
142
|
+
upload_failures += 1
|
143
|
+
rescue Exceptions::CookbookFrozen
|
144
|
+
ui.warn("Not updating version constraints for #{cookbook_name} in the environment as the cookbook is frozen.")
|
145
|
+
upload_failures += 1
|
146
|
+
rescue SystemExit => e
|
147
|
+
raise exit e.status
|
148
|
+
|
149
149
|
end
|
150
150
|
|
151
151
|
if upload_failures == 0
|
@@ -172,17 +172,17 @@ class Chef
|
|
172
172
|
else
|
173
173
|
upload_set = {}
|
174
174
|
@name_args.each do |cookbook_name|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
end
|
175
|
+
|
176
|
+
unless upload_set.key?(cookbook_name)
|
177
|
+
upload_set[cookbook_name] = cookbook_repo[cookbook_name]
|
178
|
+
if config[:depends]
|
179
|
+
upload_set[cookbook_name].metadata.dependencies.each_key { |dep| @name_args << dep }
|
181
180
|
end
|
182
|
-
rescue Exceptions::CookbookNotFoundInRepo => e
|
183
|
-
ui.error(e.message)
|
184
|
-
Log.debug(e)
|
185
181
|
end
|
182
|
+
rescue Exceptions::CookbookNotFoundInRepo => e
|
183
|
+
ui.error(e.message)
|
184
|
+
Log.debug(e)
|
185
|
+
|
186
186
|
end
|
187
187
|
upload_set
|
188
188
|
end
|
@@ -53,7 +53,7 @@ class Chef
|
|
53
53
|
paths = manifest[KEY]["plugins_paths"][command]
|
54
54
|
if paths && paths.is_a?(Array)
|
55
55
|
# It is only an error if all the paths don't exist
|
56
|
-
if paths.all? { |sc| !File.
|
56
|
+
if paths.all? { |sc| !File.exist?(sc) }
|
57
57
|
errors[command] = paths
|
58
58
|
end
|
59
59
|
end
|
@@ -77,7 +77,7 @@ class Chef
|
|
77
77
|
false
|
78
78
|
else
|
79
79
|
paths.each do |sc|
|
80
|
-
if File.
|
80
|
+
if File.exist?(sc)
|
81
81
|
Kernel.load sc
|
82
82
|
else
|
83
83
|
return false
|
@@ -41,20 +41,6 @@ class Chef
|
|
41
41
|
super(config, run_list, chef_config, secret)
|
42
42
|
end
|
43
43
|
|
44
|
-
# This is a duplicate of ChefConfig::PathHelper.cleanpath, however
|
45
|
-
# this presumes Windows so we can avoid changing the method definitions
|
46
|
-
# across Chef, ChefConfig, and ChefUtils for the circumstance where
|
47
|
-
# the methods are being run for a system other than the one Ruby is
|
48
|
-
# executing on.
|
49
|
-
#
|
50
|
-
# We only need to cleanpath the paths that we are passing to cmd.exe,
|
51
|
-
# anything written to a configuration file or passed as an argument
|
52
|
-
# will be interpreted by ruby later and do the right thing.
|
53
|
-
def cleanpath(path)
|
54
|
-
path = Pathname.new(path).cleanpath.to_s
|
55
|
-
path.gsub(File::SEPARATOR, '\\')
|
56
|
-
end
|
57
|
-
|
58
44
|
def validation_key
|
59
45
|
if File.exist?(File.expand_path(chef_config[:validation_key]))
|
60
46
|
IO.read(File.expand_path(chef_config[:validation_key]))
|
@@ -72,12 +58,21 @@ class Chef
|
|
72
58
|
end
|
73
59
|
|
74
60
|
def config_content
|
61
|
+
# The windows: true / windows: false in the block that follows is more than a bit weird. The way to read this is that we need
|
62
|
+
# the e.g. var_chef_dir to be rendered for the windows value ("C:\chef"), but then we are rendering into a file to be read by
|
63
|
+
# ruby, so we don't actually care about forward-vs-backslashes and by rendering into unix we avoid having to deal with the
|
64
|
+
# double-backwhacking of everything. So we expect to see:
|
65
|
+
#
|
66
|
+
# file_cache_path "C:/chef"
|
67
|
+
#
|
68
|
+
# Which is mildly odd, but should be entirely correct as far as ruby cares.
|
69
|
+
#
|
75
70
|
client_rb = <<~CONFIG
|
76
71
|
chef_server_url "#{chef_config[:chef_server_url]}"
|
77
72
|
validation_client_name "#{chef_config[:validation_client_name]}"
|
78
|
-
file_cache_path "#{ChefConfig::Config.var_chef_dir(true)}
|
79
|
-
file_backup_path "#{ChefConfig::Config.var_chef_dir(true)}
|
80
|
-
cache_options ({:path => "#{ChefConfig::Config.etc_chef_dir(true)}
|
73
|
+
file_cache_path "#{ChefConfig::PathHelper.escapepath(ChefConfig::Config.var_chef_dir(windows: true))}\\\\cache"
|
74
|
+
file_backup_path "#{ChefConfig::PathHelper.escapepath(ChefConfig::Config.var_chef_dir(windows: true))}\\\\backup"
|
75
|
+
cache_options ({:path => "#{ChefConfig::PathHelper.escapepath(ChefConfig::Config.etc_chef_dir(windows: true))}\\\\cache\\\\checksums", :skip_expires => true})
|
81
76
|
CONFIG
|
82
77
|
|
83
78
|
unless chef_config[:chef_license].nil?
|
@@ -90,8 +85,8 @@ class Chef
|
|
90
85
|
client_rb << "# Using default node name (fqdn)\n"
|
91
86
|
end
|
92
87
|
|
93
|
-
if
|
94
|
-
client_rb << %Q{log_level :#{
|
88
|
+
if config[:config_log_level]
|
89
|
+
client_rb << %Q{log_level :#{config[:config_log_level]}\n}
|
95
90
|
else
|
96
91
|
client_rb << "log_level :auto\n"
|
97
92
|
end
|
@@ -140,11 +135,11 @@ class Chef
|
|
140
135
|
end
|
141
136
|
|
142
137
|
if config[:secret]
|
143
|
-
client_rb << %Q{encrypted_data_bag_secret "#{ChefConfig::Config.etc_chef_dir(true)}/encrypted_data_bag_secret"\n}
|
138
|
+
client_rb << %Q{encrypted_data_bag_secret "#{ChefConfig::Config.etc_chef_dir(windows: true)}/encrypted_data_bag_secret"\n}
|
144
139
|
end
|
145
140
|
|
146
141
|
unless trusted_certs_script.empty?
|
147
|
-
client_rb << %Q{trusted_certs_dir "#{ChefConfig::Config.etc_chef_dir(true)}/trusted_certs"\n}
|
142
|
+
client_rb << %Q{trusted_certs_dir "#{ChefConfig::Config.etc_chef_dir(windows: true)}/trusted_certs"\n}
|
148
143
|
end
|
149
144
|
|
150
145
|
if chef_config[:fips]
|
@@ -173,9 +168,14 @@ class Chef
|
|
173
168
|
end
|
174
169
|
|
175
170
|
def start_chef
|
171
|
+
c_opscode_dir = ChefConfig::PathHelper.cleanpath(ChefConfig::Config.c_opscode_dir, windows: true)
|
172
|
+
client_rb = clean_etc_chef_file("client.rb")
|
173
|
+
first_boot = clean_etc_chef_file("first-boot.json")
|
174
|
+
|
176
175
|
bootstrap_environment_option = bootstrap_environment.nil? ? "" : " -E #{bootstrap_environment}"
|
177
|
-
|
178
|
-
start_chef
|
176
|
+
|
177
|
+
start_chef = "SET \"PATH=%SYSTEM32%;%SystemRoot%;%SYSTEM32%\\Wbem;%SYSTEM32%\\WindowsPowerShell\\v1.0\\;C:\\ruby\\bin;#{c_opscode_dir}\\bin;#{c_opscode_dir}\\embedded\\bin\;%PATH%\"\n"
|
178
|
+
start_chef << "#{Chef::Dist::CLIENT} -c #{client_rb} -j #{first_boot}#{bootstrap_environment_option}\n"
|
179
179
|
end
|
180
180
|
|
181
181
|
def win_wget
|
@@ -275,8 +275,16 @@ class Chef
|
|
275
275
|
install_command('"') + "\n" + fallback_install_task_command
|
276
276
|
end
|
277
277
|
|
278
|
+
def clean_etc_chef_file(path)
|
279
|
+
ChefConfig::PathHelper.cleanpath(etc_chef_file(path), windows: true)
|
280
|
+
end
|
281
|
+
|
282
|
+
def etc_chef_file(path)
|
283
|
+
"#{bootstrap_directory}/#{path}"
|
284
|
+
end
|
285
|
+
|
278
286
|
def bootstrap_directory
|
279
|
-
|
287
|
+
ChefConfig::Config.etc_chef_dir(windows: true)
|
280
288
|
end
|
281
289
|
|
282
290
|
def local_download_path
|
data/lib/chef/knife/delete.rb
CHANGED
@@ -96,21 +96,21 @@ class Chef
|
|
96
96
|
found_any = false
|
97
97
|
error = false
|
98
98
|
results.each do |result|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
99
|
+
|
100
|
+
result.delete(config[:recurse])
|
101
|
+
deleted_any = true
|
102
|
+
found_any = true
|
103
|
+
rescue Chef::ChefFS::FileSystem::NotFoundError
|
104
|
+
# This is not an error unless *all* of them were not found
|
105
|
+
rescue Chef::ChefFS::FileSystem::MustDeleteRecursivelyError => e
|
106
|
+
ui.error "#{format_path_with_root(e.entry)} must be deleted recursively! Pass -r to knife delete."
|
107
|
+
found_any = true
|
108
|
+
error = true
|
109
|
+
rescue Chef::ChefFS::FileSystem::OperationNotAllowedError => e
|
110
|
+
ui.error "#{format_path_with_root(e.entry)} #{e.reason}."
|
111
|
+
found_any = true
|
112
|
+
error = true
|
113
|
+
|
114
114
|
end
|
115
115
|
if deleted_any
|
116
116
|
output("Deleted #{format_path(results[0])}")
|