chef 15.12.22-universal-mingw32 → 15.16.4-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +10 -10
- data/Rakefile +11 -17
- data/chef-universal-mingw32.gemspec +4 -4
- data/chef.gemspec +22 -4
- data/lib/chef/api_client/registration.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/base_file.rb +1 -0
- 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 +2 -2
- 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/deprecated.rb +4 -0
- data/lib/chef/environment.rb +2 -2
- data/lib/chef/exceptions.rb +3 -0
- data/lib/chef/http.rb +2 -1
- data/lib/chef/knife/bootstrap.rb +3 -3
- data/lib/chef/knife/bootstrap/train_connector.rb +1 -0
- data/lib/chef/knife/cookbook_download.rb +1 -1
- data/lib/chef/knife/cookbook_metadata.rb +1 -1
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/hashed_command_loader.rb +3 -2
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/exec.rb +2 -2
- data/lib/chef/knife/ssh.rb +20 -1
- data/lib/chef/log.rb +1 -1
- data/lib/chef/mixin/openssl_helper.rb +26 -3
- data/lib/chef/mixin/template.rb +1 -0
- data/lib/chef/node_map.rb +5 -2
- data/lib/chef/provider/mount/solaris.rb +0 -1
- data/lib/chef/provider/package/dnf/dnf_helper.py +5 -0
- data/lib/chef/provider/package/freebsd/pkgng.rb +3 -1
- data/lib/chef/provider/package/yum/yum_helper.py +4 -0
- data/lib/chef/provider/package/zypper.rb +0 -1
- data/lib/chef/provider/service/arch.rb +2 -2
- 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 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/service/upstart.rb +1 -1
- data/lib/chef/provider/yum_repository.rb +1 -1
- data/lib/chef/provider/zypper_repository.rb +1 -1
- data/lib/chef/resource.rb +2 -0
- data/lib/chef/resource/cron_access.rb +2 -2
- data/lib/chef/resource/cron_d.rb +2 -1
- data/lib/chef/resource/homebrew_cask.rb +3 -3
- data/lib/chef/resource/hostname.rb +18 -18
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/lwrp_base.rb +7 -0
- data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
- data/lib/chef/resource/sudo.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +6 -2
- data/lib/chef/resource/windows_font.rb +2 -1
- data/lib/chef/role.rb +2 -2
- data/lib/chef/shell.rb +32 -1
- data/lib/chef/shell/shell_session.rb +2 -0
- data/lib/chef/util/diff.rb +1 -1
- data/lib/chef/util/dsc/configuration_generator.rb +1 -1
- data/lib/chef/util/powershell/cmdlet.rb +1 -1
- data/lib/chef/version.rb +2 -2
- data/lib/chef/version_string.rb +1 -1
- data/lib/chef/win32/file.rb +2 -2
- data/spec/functional/knife/ssh_spec.rb +4 -4
- data/spec/functional/resource/aix_service_spec.rb +0 -1
- data/spec/functional/resource/aixinit_service_spec.rb +7 -8
- data/spec/functional/resource/apt_package_spec.rb +0 -1
- data/spec/functional/resource/bff_spec.rb +2 -2
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/cron_spec.rb +0 -1
- data/spec/functional/resource/dsc_resource_spec.rb +1 -1
- data/spec/functional/resource/insserv_spec.rb +4 -5
- data/spec/functional/resource/link_spec.rb +17 -17
- data/spec/functional/resource/rpm_spec.rb +2 -2
- data/spec/functional/resource/user/dscl_spec.rb +1 -1
- data/spec/functional/resource/user/mac_user_spec.rb +1 -1
- data/spec/functional/resource/windows_certificate_spec.rb +3 -3
- data/spec/functional/resource/windows_font_spec.rb +49 -0
- data/spec/functional/run_lock_spec.rb +2 -1
- data/spec/functional/shell_spec.rb +5 -5
- data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/integration/recipes/accumulator_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +2 -2
- data/spec/integration/recipes/lwrp_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/notifying_block_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +2 -0
- data/spec/integration/recipes/resource_load_spec.rb +1 -0
- data/spec/integration/recipes/unified_mode_spec.rb +1 -1
- data/spec/scripts/ssl-serve.rb +1 -1
- data/spec/spec_helper.rb +10 -8
- data/spec/support/platform_helpers.rb +12 -42
- 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 +2 -2
- 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/knife_support.rb +2 -5
- data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +2 -4
- data/spec/unit/cookbook/gem_installer_spec.rb +2 -1
- data/spec/unit/dsl/platform_introspection_spec.rb +1 -0
- data/spec/unit/environment_spec.rb +7 -7
- data/spec/unit/event_dispatch/dispatcher_spec.rb +3 -0
- 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/cookbook_upload_spec.rb +5 -6
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +3 -3
- data/spec/unit/knife/ssh_spec.rb +2 -2
- data/spec/unit/knife/supermarket_share_spec.rb +5 -3
- data/spec/unit/lwrp_spec.rb +4 -4
- data/spec/unit/mixin/securable_spec.rb +0 -1
- data/spec/unit/property_spec.rb +5 -5
- data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -1
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -1
- data/spec/unit/provider/package/rubygems_spec.rb +5 -10
- data/spec/unit/provider/package/windows_spec.rb +30 -53
- 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/service/windows_spec.rb +2 -6
- data/spec/unit/provider/systemd_unit_spec.rb +28 -24
- data/spec/unit/provider_spec.rb +1 -0
- data/spec/unit/resource/windows_feature_powershell_spec.rb +30 -4
- data/spec/unit/resource/windows_package_spec.rb +1 -0
- data/spec/unit/role_spec.rb +11 -11
- data/spec/unit/run_context/cookbook_compiler_spec.rb +1 -1
- data/spec/unit/win32/security_spec.rb +4 -3
- metadata +48 -29
@@ -125,7 +125,7 @@ class Chef
|
|
125
125
|
#
|
126
126
|
def find_subcommands_via_dirglob
|
127
127
|
# The "require paths" of the core knife subcommands bundled with chef
|
128
|
-
files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("
|
128
|
+
files = Dir[File.join(Chef::Util::PathHelper.escape_glob_dir(File.expand_path("../../knife", __dir__)), "*.rb")]
|
129
129
|
subcommand_files = {}
|
130
130
|
files.each do |knife_file|
|
131
131
|
rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
|
data/lib/chef/knife/exec.rb
CHANGED
@@ -76,7 +76,7 @@ class Chef::Knife::Exec < Chef::Knife
|
|
76
76
|
def find_script(x)
|
77
77
|
# Try to find a script. First try expanding the path given.
|
78
78
|
script = File.expand_path(x)
|
79
|
-
return script if File.
|
79
|
+
return script if File.exist?(script)
|
80
80
|
|
81
81
|
# Failing that, try searching the script path. If we can't find
|
82
82
|
# anything, fail gracefully.
|
@@ -86,7 +86,7 @@ class Chef::Knife::Exec < Chef::Knife
|
|
86
86
|
path = File.expand_path(path)
|
87
87
|
test = File.join(path, x)
|
88
88
|
Chef::Log.trace("Testing: #{test}")
|
89
|
-
if File.
|
89
|
+
if File.exist?(test)
|
90
90
|
script = test
|
91
91
|
Chef::Log.trace("Found: #{test}")
|
92
92
|
return script
|
data/lib/chef/knife/ssh.rb
CHANGED
@@ -298,6 +298,10 @@ class Chef
|
|
298
298
|
opts[:keepalive] = true
|
299
299
|
opts[:keepalive_interval] = ssh_config[:keepalive_interval]
|
300
300
|
end
|
301
|
+
# maintain support for legacy key types / ciphers / key exchange algorithms.
|
302
|
+
# most importantly this adds back support for DSS host keys
|
303
|
+
# See https://github.com/net-ssh/net-ssh/pull/709
|
304
|
+
opts[:append_all_supported_algorithms] = true
|
301
305
|
end
|
302
306
|
end
|
303
307
|
|
@@ -358,11 +362,21 @@ class Chef
|
|
358
362
|
subsession ||= session
|
359
363
|
command = fixup_sudo(command)
|
360
364
|
command.force_encoding("binary") if command.respond_to?(:force_encoding)
|
365
|
+
begin
|
366
|
+
open_session(subsession, command)
|
367
|
+
rescue => e
|
368
|
+
open_session(subsession, command, true)
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
def open_session(subsession, command, pty = false)
|
373
|
+
stderr = ""
|
374
|
+
exit_status = 0
|
361
375
|
subsession.open_channel do |chan|
|
362
376
|
if config[:on_error] && exit_status != 0
|
363
377
|
chan.close
|
364
378
|
else
|
365
|
-
chan.request_pty
|
379
|
+
chan.request_pty if pty
|
366
380
|
chan.exec command do |ch, success|
|
367
381
|
raise ArgumentError, "Cannot execute #{command}" unless success
|
368
382
|
|
@@ -373,6 +387,11 @@ class Chef
|
|
373
387
|
ichannel.send_data("#{get_password}\n")
|
374
388
|
end
|
375
389
|
end
|
390
|
+
|
391
|
+
ch.on_extended_data do |_, _type, data|
|
392
|
+
stderr += data
|
393
|
+
end
|
394
|
+
|
376
395
|
ch.on_request "exit-status" do |ichannel, data|
|
377
396
|
exit_status = [exit_status, data.read_long].max
|
378
397
|
end
|
data/lib/chef/log.rb
CHANGED
@@ -47,7 +47,7 @@ class Chef
|
|
47
47
|
def self.caller_location
|
48
48
|
# Pick the first caller that is *not* part of the Chef gem, that's the
|
49
49
|
# thing the user wrote. Or failing that, the most recent caller.
|
50
|
-
chef_gem_path = File.expand_path("
|
50
|
+
chef_gem_path = File.expand_path("..", __dir__)
|
51
51
|
caller(0..20).find { |c| !c.start_with?(chef_gem_path) } || caller(0..1)[0]
|
52
52
|
end
|
53
53
|
|
@@ -282,7 +282,9 @@ class Chef
|
|
282
282
|
ef.issuer_certificate = info["issuer"]
|
283
283
|
end
|
284
284
|
ef.subject_certificate = cert
|
285
|
-
|
285
|
+
if openssl_config = __openssl_config
|
286
|
+
ef.config = openssl_config
|
287
|
+
end
|
286
288
|
|
287
289
|
cert.extensions = extension
|
288
290
|
cert.add_extension ef.create_extension("subjectKeyIdentifier", "hash")
|
@@ -313,7 +315,9 @@ class Chef
|
|
313
315
|
crl.last_update = Time.now
|
314
316
|
crl.next_update = Time.now + 3600 * 24 * info["validity"]
|
315
317
|
|
316
|
-
|
318
|
+
if openssl_config = __openssl_config
|
319
|
+
ef.config = openssl_config
|
320
|
+
end
|
317
321
|
ef.issuer_certificate = info["issuer"]
|
318
322
|
|
319
323
|
crl.add_extension ::OpenSSL::X509::Extension.new("crlNumber", ::OpenSSL::ASN1::Integer(1))
|
@@ -391,7 +395,9 @@ class Chef
|
|
391
395
|
crl.next_update = crl.last_update + 3600 * 24 * info["validity"]
|
392
396
|
|
393
397
|
ef = ::OpenSSL::X509::ExtensionFactory.new
|
394
|
-
|
398
|
+
if openssl_config = __openssl_config
|
399
|
+
ef.config = openssl_config
|
400
|
+
end
|
395
401
|
ef.issuer_certificate = info["issuer"]
|
396
402
|
|
397
403
|
crl.extensions = [ ::OpenSSL::X509::Extension.new("crlNumber",
|
@@ -422,6 +428,23 @@ class Chef
|
|
422
428
|
|
423
429
|
resp
|
424
430
|
end
|
431
|
+
|
432
|
+
private
|
433
|
+
|
434
|
+
def __openssl_config
|
435
|
+
path = if File.exist?(::OpenSSL::Config::DEFAULT_CONFIG_FILE)
|
436
|
+
OpenSSL::Config::DEFAULT_CONFIG_FILE
|
437
|
+
else
|
438
|
+
Dir[File.join(RbConfig::CONFIG["prefix"], "**", "openssl.cnf")].first
|
439
|
+
end
|
440
|
+
|
441
|
+
if File.exist?(path)
|
442
|
+
::OpenSSL::Config.load(path)
|
443
|
+
else
|
444
|
+
Chef::Log.warn("Couldn't find OpenSSL config file")
|
445
|
+
nil
|
446
|
+
end
|
447
|
+
end
|
425
448
|
end
|
426
449
|
end
|
427
450
|
end
|
data/lib/chef/mixin/template.rb
CHANGED
data/lib/chef/node_map.rb
CHANGED
@@ -35,10 +35,13 @@
|
|
35
35
|
#
|
36
36
|
# XXX: confusingly, in the *_priority_map the :klass may be an array of Strings of class names
|
37
37
|
#
|
38
|
+
|
39
|
+
require_relative "dist"
|
40
|
+
|
38
41
|
class Chef
|
39
42
|
class NodeMap
|
40
43
|
COLLISION_WARNING = <<~EOH.gsub(/\s+/, " ").strip
|
41
|
-
%{type_caps} %{key}
|
44
|
+
%{type_caps} %{key} built into %{client_name} is being overridden by the %{type} from a cookbook. Please upgrade your cookbook
|
42
45
|
or remove the cookbook from your run_list.
|
43
46
|
EOH
|
44
47
|
|
@@ -84,7 +87,7 @@ class Chef
|
|
84
87
|
else
|
85
88
|
klass.superclass.to_s
|
86
89
|
end
|
87
|
-
Chef::Log.warn( COLLISION_WARNING % { type: type_of_thing, key: key, type_caps: type_of_thing.capitalize } )
|
90
|
+
Chef::Log.warn( COLLISION_WARNING % { type: type_of_thing, key: key, type_caps: type_of_thing.capitalize, client_name: Chef::Dist::PRODUCT } )
|
88
91
|
end
|
89
92
|
|
90
93
|
# The map is sorted in order of preference already; we just need to find
|
@@ -101,6 +101,11 @@ while 1:
|
|
101
101
|
if ppid == 1:
|
102
102
|
sys.exit(0)
|
103
103
|
line = sys.stdin.readline()
|
104
|
+
|
105
|
+
# only way to detect EOF in python
|
106
|
+
if line == "":
|
107
|
+
break
|
108
|
+
|
104
109
|
command = json.loads(line)
|
105
110
|
if command['action'] == "whatinstalled":
|
106
111
|
query(command)
|
@@ -42,7 +42,9 @@ class Chef
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def current_installed_version
|
45
|
-
|
45
|
+
# pkgng up to version 1.15.99.7 returns 70 for pkg not found,
|
46
|
+
# later versions return 1
|
47
|
+
pkg_info = shell_out!("pkg", "info", new_resource.package_name, env: nil, returns: [0, 1, 70])
|
46
48
|
pkg_info.stdout[/^Version +: (.+)$/, 1]
|
47
49
|
end
|
48
50
|
|
@@ -32,8 +32,8 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def load_current_resource
|
35
|
-
raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.
|
36
|
-
raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf")
|
35
|
+
raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exist?("/etc/rc.conf")
|
36
|
+
raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless /DAEMONS=\((.*)\)/m.match?(::File.read("/etc/rc.conf"))
|
37
37
|
|
38
38
|
super
|
39
39
|
|
@@ -45,7 +45,7 @@ class Chef
|
|
45
45
|
shared_resource_requirements
|
46
46
|
requirements.assert(:all_actions) do |a|
|
47
47
|
update_rcd = "/usr/sbin/update-rc.d"
|
48
|
-
a.assertion { ::File.
|
48
|
+
a.assertion { ::File.exist? update_rcd }
|
49
49
|
a.failure_message Chef::Exceptions::Service, "#{update_rcd} does not exist!"
|
50
50
|
# no whyrun recovery - this is a base system component of debian
|
51
51
|
# distros and must be present
|
@@ -34,7 +34,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
|
|
34
34
|
@current_resource.enabled(
|
35
35
|
Dir.glob("/etc/runlevels/**/#{Chef::Util::PathHelper.escape_glob_dir(@current_resource.service_name)}").any? do |file|
|
36
36
|
@found_script = true
|
37
|
-
exists = ::File.
|
37
|
+
exists = ::File.exist? file
|
38
38
|
readable = ::File.readable? file
|
39
39
|
logger.trace "#{@new_resource} exists: #{exists}, readable: #{readable}"
|
40
40
|
exists && readable
|
@@ -47,7 +47,7 @@ class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
|
|
47
47
|
|
48
48
|
def define_resource_requirements
|
49
49
|
requirements.assert(:all_actions) do |a|
|
50
|
-
a.assertion { ::File.
|
50
|
+
a.assertion { ::File.exist?("/sbin/rc-update") }
|
51
51
|
a.failure_message Chef::Exceptions::Service, "/sbin/rc-update does not exist"
|
52
52
|
# no whyrun recovery -t his is a core component whose presence is
|
53
53
|
# unlikely to be affected by what we do in the course of a chef run
|
@@ -84,7 +84,7 @@ class Chef
|
|
84
84
|
end
|
85
85
|
|
86
86
|
requirements.assert(:all_actions) do |a|
|
87
|
-
a.assertion { ::File.
|
87
|
+
a.assertion { ::File.exist?(@plist.to_s) }
|
88
88
|
a.failure_message Chef::Exceptions::Service,
|
89
89
|
"Could not find plist for #{@new_resource}"
|
90
90
|
end
|
@@ -215,7 +215,7 @@ class Chef
|
|
215
215
|
return nil if @plist.nil?
|
216
216
|
|
217
217
|
# Plist must exist by this point
|
218
|
-
raise Chef::Exceptions::FileNotFound, "Cannot find #{@plist}!" unless ::File.
|
218
|
+
raise Chef::Exceptions::FileNotFound, "Cannot find #{@plist}!" unless ::File.exist?(@plist)
|
219
219
|
|
220
220
|
# Most services have the same internal label as the name of the
|
221
221
|
# plist file. However, there is no rule saying that *has* to be
|
@@ -132,7 +132,7 @@ class Chef
|
|
132
132
|
end
|
133
133
|
|
134
134
|
def update_rcl(value)
|
135
|
-
FileUtils.touch RC_CONF_LOCAL_PATH unless ::File.
|
135
|
+
FileUtils.touch RC_CONF_LOCAL_PATH unless ::File.exist? RC_CONF_LOCAL_PATH
|
136
136
|
::File.write(RC_CONF_LOCAL_PATH, value)
|
137
137
|
@rc_conf_local = value
|
138
138
|
end
|
@@ -56,7 +56,7 @@ class Chef
|
|
56
56
|
|
57
57
|
requirements.assert(:all_actions) do |a|
|
58
58
|
chkconfig_file = "/sbin/chkconfig"
|
59
|
-
a.assertion { ::File.
|
59
|
+
a.assertion { ::File.exist? chkconfig_file }
|
60
60
|
a.failure_message Chef::Exceptions::Service, "#{chkconfig_file} does not exist!"
|
61
61
|
end
|
62
62
|
|
@@ -80,7 +80,7 @@ class Chef
|
|
80
80
|
|
81
81
|
super
|
82
82
|
|
83
|
-
if ::File.
|
83
|
+
if ::File.exist?("/sbin/chkconfig")
|
84
84
|
chkconfig = shell_out!("/sbin/chkconfig --list #{current_resource.service_name}", returns: [0, 1])
|
85
85
|
unless run_levels.nil? || run_levels.empty?
|
86
86
|
all_levels_match = true
|
@@ -135,7 +135,7 @@ class Chef
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
# Get enabled/disabled state by reading job configuration file
|
138
|
-
if ::File.
|
138
|
+
if ::File.exist?("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
|
139
139
|
logger.trace("#{@new_resource} found #{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}")
|
140
140
|
::File.open("#{@upstart_job_dir}/#{@new_resource.service_name}#{@upstart_conf_suffix}", "r") do |file|
|
141
141
|
while line = file.gets
|
@@ -37,7 +37,7 @@ class Chef
|
|
37
37
|
if template_available?(new_resource.source)
|
38
38
|
source new_resource.source
|
39
39
|
else
|
40
|
-
source ::File.expand_path("
|
40
|
+
source ::File.expand_path("support/yum_repo.erb", __dir__)
|
41
41
|
local true
|
42
42
|
end
|
43
43
|
sensitive new_resource.sensitive
|
@@ -41,7 +41,7 @@ class Chef
|
|
41
41
|
if template_available?(new_resource.source)
|
42
42
|
source new_resource.source
|
43
43
|
else
|
44
|
-
source ::File.expand_path("
|
44
|
+
source ::File.expand_path("support/zypper_repo.erb", __dir__)
|
45
45
|
local true
|
46
46
|
end
|
47
47
|
sensitive new_resource.sensitive
|
data/lib/chef/resource.rb
CHANGED
@@ -613,6 +613,7 @@ class Chef
|
|
613
613
|
# Do NOT use this. It may be removed. It is for internal purposes only.
|
614
614
|
# @api private
|
615
615
|
attr_reader :resource_initializing
|
616
|
+
|
616
617
|
def resource_initializing=(value)
|
617
618
|
if value
|
618
619
|
@resource_initializing = true
|
@@ -863,6 +864,7 @@ class Chef
|
|
863
864
|
# have.
|
864
865
|
#
|
865
866
|
attr_writer :allowed_actions
|
867
|
+
|
866
868
|
def allowed_actions(value = NOT_PASSED)
|
867
869
|
if value != NOT_PASSED
|
868
870
|
self.allowed_actions = value
|
@@ -66,7 +66,7 @@ class Chef
|
|
66
66
|
|
67
67
|
with_run_context :root do
|
68
68
|
edit_resource(:template, allow_path) do |new_resource|
|
69
|
-
source ::File.expand_path("
|
69
|
+
source ::File.expand_path("support/cron_access.erb", __dir__)
|
70
70
|
local true
|
71
71
|
mode "0600"
|
72
72
|
variables["users"] ||= []
|
@@ -83,7 +83,7 @@ class Chef
|
|
83
83
|
|
84
84
|
with_run_context :root do
|
85
85
|
edit_resource(:template, deny_path) do |new_resource|
|
86
|
-
source ::File.expand_path("
|
86
|
+
source ::File.expand_path("support/cron_access.erb", __dir__)
|
87
87
|
local true
|
88
88
|
mode "0600"
|
89
89
|
variables["users"] ||= []
|
data/lib/chef/resource/cron_d.rb
CHANGED
@@ -289,9 +289,10 @@ class Chef
|
|
289
289
|
|
290
290
|
# @todo this is Chef 12 era cleanup. Someday we should remove it all
|
291
291
|
template "/etc/cron.d/#{sanitized_name}" do
|
292
|
-
source ::File.expand_path("
|
292
|
+
source ::File.expand_path("support/cron.d.erb", __dir__)
|
293
293
|
local true
|
294
294
|
mode new_resource.mode
|
295
|
+
sensitive new_resource.sensitive
|
295
296
|
variables(
|
296
297
|
name: sanitized_name,
|
297
298
|
predefined_value: new_resource.predefined_value,
|
@@ -59,7 +59,7 @@ class Chef
|
|
59
59
|
|
60
60
|
unless casked?
|
61
61
|
converge_by("install cask #{new_resource.cask_name} #{new_resource.options}") do
|
62
|
-
shell_out!("#{new_resource.homebrew_path} cask
|
62
|
+
shell_out!("#{new_resource.homebrew_path} install --cask #{new_resource.cask_name} #{new_resource.options}",
|
63
63
|
user: new_resource.owner,
|
64
64
|
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
|
65
65
|
cwd: ::Dir.home(new_resource.owner))
|
@@ -74,7 +74,7 @@ class Chef
|
|
74
74
|
|
75
75
|
if casked?
|
76
76
|
converge_by("uninstall cask #{new_resource.cask_name}") do
|
77
|
-
shell_out!("#{new_resource.homebrew_path} cask
|
77
|
+
shell_out!("#{new_resource.homebrew_path} uninstall --cask #{new_resource.cask_name}",
|
78
78
|
user: new_resource.owner,
|
79
79
|
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
|
80
80
|
cwd: ::Dir.home(new_resource.owner))
|
@@ -92,7 +92,7 @@ class Chef
|
|
92
92
|
# @return [Boolean]
|
93
93
|
def casked?
|
94
94
|
unscoped_name = new_resource.cask_name.split("/").last
|
95
|
-
shell_out!("#{new_resource.homebrew_path} cask
|
95
|
+
shell_out!("#{new_resource.homebrew_path} list --cask 2>/dev/null",
|
96
96
|
user: new_resource.owner,
|
97
97
|
env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
|
98
98
|
cwd: ::Dir.home(new_resource.owner)).stdout.split.include?(unscoped_name)
|
@@ -67,8 +67,7 @@ class Chef
|
|
67
67
|
def updated_ec2_config_xml
|
68
68
|
begin
|
69
69
|
require "rexml/document" unless defined?(REXML::Document)
|
70
|
-
|
71
|
-
config = REXML::Document.new(::File.read(config_file))
|
70
|
+
config = REXML::Document.new(::File.read(WINDOWS_EC2_CONFIG))
|
72
71
|
# find an element named State with a sibling element whose value is Ec2SetComputerName
|
73
72
|
REXML::XPath.each(config, "//Plugin/State[../Name/text() = 'Ec2SetComputerName']") do |element|
|
74
73
|
element.text = "Disabled"
|
@@ -220,35 +219,36 @@ class Chef
|
|
220
219
|
end
|
221
220
|
|
222
221
|
else # windows
|
222
|
+
WINDOWS_EC2_CONFIG = 'C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml'.freeze
|
223
|
+
|
223
224
|
raise "Windows hostnames cannot contain a period." if new_resource.hostname.match?(/\./)
|
224
225
|
|
225
226
|
# suppress EC2 config service from setting our hostname
|
226
|
-
if ::File.exist?(
|
227
|
+
if ::File.exist?(WINDOWS_EC2_CONFIG)
|
227
228
|
xml_contents = updated_ec2_config_xml
|
228
229
|
if xml_contents.empty?
|
229
230
|
Chef::Log.warn('Unable to properly parse and update C:\Program Files\Amazon\Ec2ConfigService\Settings\config.xml contents. Skipping file update.')
|
230
231
|
else
|
231
|
-
|
232
|
+
file WINDOWS_EC2_CONFIG do
|
232
233
|
content xml_contents
|
233
234
|
end
|
234
235
|
end
|
235
236
|
end
|
236
237
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
not_if { Socket.gethostbyname(Socket.gethostname).first == new_resource.hostname }
|
245
|
-
end
|
238
|
+
unless Socket.gethostbyname(Socket.gethostname).first == new_resource.hostname
|
239
|
+
converge_by "set hostname to #{new_resource.hostname}" do
|
240
|
+
powershell_out! <<~EOH
|
241
|
+
$sysInfo = Get-WmiObject -Class Win32_ComputerSystem
|
242
|
+
$sysInfo.Rename("#{new_resource.hostname}")
|
243
|
+
EOH
|
244
|
+
end
|
246
245
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
246
|
+
# reboot because $windows
|
247
|
+
reboot "setting hostname" do
|
248
|
+
reason "#{Chef::Dist::PRODUCT} updated system hostname"
|
249
|
+
only_if { new_resource.windows_reboot }
|
250
|
+
action :request_reboot
|
251
|
+
end
|
252
252
|
end
|
253
253
|
end
|
254
254
|
end
|