chef 15.4.45-universal-mingw32 → 15.5.9-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 +5 -3
- data/Rakefile +5 -3
- data/chef.gemspec +2 -1
- data/ext/win32-eventlog/Rakefile +9 -1
- data/ext/win32-eventlog/{chef-log.man → chef-log.man.erb} +4 -4
- data/lib/chef/application.rb +2 -2
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -0
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/chef_class.rb +1 -6
- data/lib/chef/chef_fs.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +2 -2
- data/lib/chef/client.rb +4 -5
- data/lib/chef/config.rb +3 -2
- data/lib/chef/cookbook/chefignore.rb +16 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +5 -3
- data/lib/chef/cookbook_loader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/data_collector.rb +2 -2
- data/lib/chef/data_collector/run_end_message.rb +1 -0
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/dsl/core.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +9 -18
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/file_content_management/deploy.rb +3 -3
- data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/knife.rb +4 -3
- data/lib/chef/knife/config_get.rb +2 -1
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +6 -0
- data/lib/chef/local_mode.rb +1 -1
- data/lib/chef/mash.rb +21 -232
- data/lib/chef/mixin/file_class.rb +2 -2
- data/lib/chef/mixin/lazy_module_include.rb +1 -1
- data/lib/chef/mixin/path_sanity.rb +3 -39
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +4 -5
- data/lib/chef/mixin/template.rb +1 -1
- data/lib/chef/mixin/user_context.rb +3 -3
- data/lib/chef/mixin/which.rb +10 -38
- data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
- data/lib/chef/mixin/windows_env_helper.rb +5 -5
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node_map.rb +17 -4
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +14 -85
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/link.rb +3 -3
- data/lib/chef/provider/mount/solaris.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file/fetcher.rb +2 -2
- data/lib/chef/provider/remote_file/local_file.rb +1 -1
- data/lib/chef/provider/script.rb +3 -3
- data/lib/chef/provider/service.rb +5 -2
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +4 -4
- data/lib/chef/provider/service/init.rb +1 -1
- data/lib/chef/provider/service/insserv.rb +4 -4
- data/lib/chef/provider/service/invokercd.rb +4 -4
- data/lib/chef/provider/service/redhat.rb +4 -4
- data/lib/chef/provider/service/systemd.rb +19 -3
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/subversion.rb +1 -1
- data/lib/chef/provider/systemd_unit.rb +26 -2
- data/lib/chef/provider/windows_path.rb +3 -3
- data/lib/chef/provider/windows_task.rb +4 -4
- data/lib/chef/resource.rb +1 -0
- data/lib/chef/resource/bash.rb +2 -0
- data/lib/chef/resource/batch.rb +2 -0
- data/lib/chef/resource/breakpoint.rb +3 -1
- data/lib/chef/resource/build_essential.rb +3 -3
- data/lib/chef/resource/chef_sleep.rb +70 -0
- data/lib/chef/resource/cookbook_file.rb +2 -1
- data/lib/chef/resource/csh.rb +2 -0
- data/lib/chef/resource/directory.rb +2 -0
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +1 -1
- data/lib/chef/resource/execute.rb +2 -0
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +3 -1
- data/lib/chef/resource/ksh.rb +2 -0
- data/lib/chef/resource/link.rb +4 -2
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/log.rb +2 -0
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/perl.rb +2 -0
- data/lib/chef/resource/python.rb +2 -0
- data/lib/chef/resource/reboot.rb +2 -0
- data/lib/chef/resource/registry_key.rb +2 -0
- data/lib/chef/resource/remote_directory.rb +3 -2
- data/lib/chef/resource/remote_file.rb +1 -0
- data/lib/chef/resource/ruby.rb +2 -0
- data/lib/chef/resource/ruby_block.rb +2 -0
- data/lib/chef/resource/scm.rb +2 -0
- data/lib/chef/resource/script.rb +2 -0
- data/lib/chef/resource/service.rb +9 -1
- data/lib/chef/resource/solaris_package.rb +1 -1
- data/lib/chef/resource/subversion.rb +2 -0
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/systemd_unit.rb +1 -0
- data/lib/chef/resource/template.rb +2 -0
- data/lib/chef/resource/user.rb +2 -0
- data/lib/chef/resource/user/aix_user.rb +2 -0
- data/lib/chef/resource/user/linux_user.rb +2 -0
- data/lib/chef/resource/user/pw_user.rb +2 -0
- data/lib/chef/resource/user/solaris_user.rb +2 -0
- data/lib/chef/resource/user/windows_user.rb +2 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +1 -1
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +1 -1
- data/lib/chef/resource/windows_firewall_rule.rb +11 -6
- data/lib/chef/resource/windows_script.rb +3 -1
- data/lib/chef/resource/yum_package.rb +1 -1
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +1 -1
- data/lib/chef/run_lock.rb +5 -5
- data/lib/chef/search/query.rb +0 -3
- data/lib/chef/train_transport.rb +3 -1
- data/lib/chef/util/powershell/ps_credential.rb +2 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/logon_session.rb +2 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/eventlog.rb +2 -2
- data/spec/data/cookbooks/starter/chefignore +8 -0
- data/spec/data/cookbooks/starter/files/sample.txt +1 -0
- data/spec/data/cookbooks/starter/metadata.rb +2 -0
- data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
- data/spec/functional/mixin/user_context_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/cookbook_file_spec.rb +2 -2
- data/spec/functional/resource/template_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/functional/win32/sid_spec.rb +2 -2
- data/spec/functional/win32/version_info_spec.rb +1 -1
- data/spec/functional/win32/versions_spec.rb +1 -1
- data/spec/integration/knife/config_get_profile_spec.rb +2 -2
- data/spec/integration/knife/config_get_spec.rb +9 -2
- data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
- data/spec/integration/knife/config_use_profile_spec.rb +2 -2
- data/spec/integration/knife/list_spec.rb +2 -2
- data/spec/integration/solo/solo_spec.rb +1 -1
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/support/mock/platform.rb +1 -1
- data/spec/support/platform_helpers.rb +2 -0
- data/spec/support/shared/integration/integration_helper.rb +1 -1
- data/spec/support/shared/integration/knife_support.rb +1 -1
- data/spec/support/shared/unit/provider/file.rb +4 -4
- data/spec/unit/application/client_spec.rb +2 -2
- data/spec/unit/application/knife_spec.rb +17 -0
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
- data/spec/unit/chef_fs/path_util_spec.rb +3 -3
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/cookbook/chefignore_spec.rb +31 -11
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
- data/spec/unit/cookbook_loader_spec.rb +2 -2
- data/spec/unit/cookbook_uploader_spec.rb +6 -1
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +7 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
- data/spec/unit/knife/cookbook_show_spec.rb +1 -1
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
- data/spec/unit/knife/environment_from_file_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +27 -17
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife/supermarket_install_spec.rb +1 -1
- data/spec/unit/mixin/path_sanity_spec.rb +3 -3
- data/spec/unit/mixin/shell_out_spec.rb +2 -3
- data/spec/unit/mixin/template_spec.rb +4 -4
- data/spec/unit/mixin/user_context_spec.rb +3 -3
- data/spec/unit/node_map_spec.rb +12 -12
- data/spec/unit/platform/query_helpers_spec.rb +9 -9
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/openbsd_spec.rb +1 -1
- data/spec/unit/provider/package/smartos_spec.rb +1 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +2 -2
- data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
- data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
- data/spec/unit/provider/subversion_spec.rb +3 -3
- data/spec/unit/provider/systemd_unit_spec.rb +53 -4
- data/spec/unit/provider/user/dscl_spec.rb +1 -1
- data/spec/unit/provider_resolver_spec.rb +41 -61
- data/spec/unit/resource/chef_sleep_spec.rb +30 -0
- data/spec/unit/resource/cookbook_file_spec.rb +3 -3
- data/spec/unit/resource/remote_file_spec.rb +3 -3
- data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
- data/spec/unit/role_spec.rb +2 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/win32/error_spec.rb +1 -1
- data/spec/unit/win32/link_spec.rb +1 -1
- data/spec/unit/win32/security_spec.rb +1 -1
- data/spec/unit/windows_service_spec.rb +1 -1
- data/tasks/docs.rb +10 -2
- data/tasks/rspec.rb +8 -6
- metadata +33 -9
- data/lib/chef/mixin/train_helpers.rb +0 -60
- data/spec/unit/mash_spec.rb +0 -51
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Edwards (<adamed@chef.io>)
|
3
|
-
# Copyright:: Copyright 2013-
|
3
|
+
# Copyright:: Copyright 2013-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -18,8 +18,8 @@
|
|
18
18
|
|
19
19
|
require_relative "../exceptions"
|
20
20
|
require_relative "../platform/query_helpers"
|
21
|
-
require_relative "../win32/process" if
|
22
|
-
require_relative "../win32/system" if
|
21
|
+
require_relative "../win32/process" if ChefUtils.windows?
|
22
|
+
require_relative "../win32/system" if ChefUtils.windows?
|
23
23
|
|
24
24
|
class Chef
|
25
25
|
module Mixin
|
@@ -89,7 +89,7 @@ class Chef
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def is_i386_process_on_x86_64_windows?
|
92
|
-
if
|
92
|
+
if ChefUtils.windows?
|
93
93
|
Chef::ReservedNames::Win32::Process.is_wow64_process
|
94
94
|
else
|
95
95
|
false
|
@@ -97,13 +97,13 @@ class Chef
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def disable_wow64_file_redirection( node )
|
100
|
-
if ( node_windows_architecture(node) == :x86_64) && ::
|
100
|
+
if ( node_windows_architecture(node) == :x86_64) && ::ChefUtils.windows?
|
101
101
|
Chef::ReservedNames::Win32::System.wow64_disable_wow64_fs_redirection
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
105
|
def restore_wow64_file_redirection( node, original_redirection_state )
|
106
|
-
if (node_windows_architecture(node) == :x86_64) && ::
|
106
|
+
if (node_windows_architecture(node) == :x86_64) && ::ChefUtils.windows?
|
107
107
|
Chef::ReservedNames::Win32::System.wow64_revert_wow64_fs_redirection(original_redirection_state)
|
108
108
|
end
|
109
109
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Edwards (<adamed@chef.io>)
|
3
|
-
# Copyright:: Copyright 2013-
|
3
|
+
# Copyright:: Copyright 2013-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -19,16 +19,16 @@
|
|
19
19
|
require_relative "../exceptions"
|
20
20
|
require_relative "wide_string"
|
21
21
|
require_relative "../platform/query_helpers"
|
22
|
-
require_relative "../win32/error" if
|
23
|
-
require_relative "../win32/api/system" if
|
24
|
-
require_relative "../win32/api/unicode" if
|
22
|
+
require_relative "../win32/error" if ChefUtils.windows?
|
23
|
+
require_relative "../win32/api/system" if ChefUtils.windows?
|
24
|
+
require_relative "../win32/api/unicode" if ChefUtils.windows?
|
25
25
|
|
26
26
|
class Chef
|
27
27
|
module Mixin
|
28
28
|
module WindowsEnvHelper
|
29
29
|
include Chef::Mixin::WideString
|
30
30
|
|
31
|
-
if
|
31
|
+
if ChefUtils.windows?
|
32
32
|
include Chef::ReservedNames::Win32::API::System
|
33
33
|
end
|
34
34
|
|
data/lib/chef/node/attribute.rb
CHANGED
@@ -199,14 +199,14 @@ class Chef
|
|
199
199
|
@role_default = VividMash.new({}, self, node, :role_default)
|
200
200
|
@force_default = VividMash.new({}, self, node, :force_default)
|
201
201
|
|
202
|
-
@normal
|
202
|
+
@normal = VividMash.new(normal, self, node, :normal)
|
203
203
|
|
204
204
|
@override = VividMash.new(override, self, node, :override)
|
205
205
|
@role_override = VividMash.new({}, self, node, :role_override)
|
206
206
|
@env_override = VividMash.new({}, self, node, :env_override)
|
207
207
|
@force_override = VividMash.new({}, self, node, :force_override)
|
208
208
|
|
209
|
-
@automatic
|
209
|
+
@automatic = VividMash.new(automatic, self, node, :automatic)
|
210
210
|
|
211
211
|
super(nil, self, node, :merged)
|
212
212
|
end
|
data/lib/chef/node_map.rb
CHANGED
@@ -219,6 +219,11 @@ class Chef
|
|
219
219
|
|
220
220
|
private
|
221
221
|
|
222
|
+
def platform_family_query_helper?(node, m)
|
223
|
+
method = "#{m}?".to_sym
|
224
|
+
ChefUtils::DSL::PlatformFamily.respond_to?(method) && ChefUtils::DSL::PlatformFamily.send(method, node)
|
225
|
+
end
|
226
|
+
|
222
227
|
#
|
223
228
|
# Succeeds if:
|
224
229
|
# - no negative matches (!value)
|
@@ -235,11 +240,19 @@ class Chef
|
|
235
240
|
# Split the blacklist and whitelist
|
236
241
|
blacklist, whitelist = filter_values.partition { |v| v.is_a?(String) && v.start_with?("!") }
|
237
242
|
|
238
|
-
|
239
|
-
|
243
|
+
if attribute == :platform_family
|
244
|
+
# If any blacklist value matches, we don't match
|
245
|
+
return false if blacklist.any? { |v| v[1..-1] == value || platform_family_query_helper?(node, v[1..-1]) }
|
240
246
|
|
241
|
-
|
242
|
-
|
247
|
+
# If the whitelist is empty, or anything matches, we match.
|
248
|
+
whitelist.empty? || whitelist.any? { |v| v == :all || v == value || platform_family_query_helper?(node, v) }
|
249
|
+
else
|
250
|
+
# If any blacklist value matches, we don't match
|
251
|
+
return false if blacklist.any? { |v| v[1..-1] == value }
|
252
|
+
|
253
|
+
# If the whitelist is empty, or anything matches, we match.
|
254
|
+
whitelist.empty? || whitelist.any? { |v| v == :all || v == value }
|
255
|
+
end
|
243
256
|
end
|
244
257
|
|
245
258
|
def matches_version_list?(node, filters, attribute)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -16,12 +16,14 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
+
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
20
|
+
|
19
21
|
class Chef
|
20
22
|
class Platform
|
21
23
|
|
22
24
|
class << self
|
23
25
|
def windows?
|
24
|
-
|
26
|
+
ChefUtils.windows?
|
25
27
|
end
|
26
28
|
|
27
29
|
def windows_nano_server?
|
@@ -35,7 +35,7 @@ class Chef
|
|
35
35
|
reboot_info = node.run_context.reboot_info
|
36
36
|
|
37
37
|
cmd = case
|
38
|
-
when
|
38
|
+
when ChefUtils.windows?
|
39
39
|
# should this do /f as well? do we then need a minimum delay to let apps quit?
|
40
40
|
# Use explicit path to shutdown.exe, to protect against https://github.com/chef/chef/issues/5594
|
41
41
|
windows_shutdown_path = "#{ENV["SYSTEMROOT"]}/System32/shutdown.exe"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Lamont Granquist (<lamont@chef.io>)
|
3
|
-
# Copyright:: Copyright 2014-
|
3
|
+
# Copyright:: Copyright 2014-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -17,53 +17,22 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require_relative "../chef_class"
|
20
|
-
|
20
|
+
require "chef-utils" if defined?(ChefUtils::CANARY)
|
21
21
|
|
22
22
|
class Chef
|
23
23
|
class Platform
|
24
|
+
# @deprecated, use ChefUtils::DSL::Service instead (via the ChefUtils Universal DSL)
|
24
25
|
class ServiceHelpers
|
25
26
|
class << self
|
26
|
-
include Chef::Mixin::TrainHelpers
|
27
|
-
|
28
|
-
# This helper is mostly used to sort out the mess of different
|
29
|
-
# linux mechanisms that can be used to start services. It does
|
30
|
-
# not necessarily need to linux-specific, but currently all our
|
31
|
-
# other service providers are narrowly platform-specific with no
|
32
|
-
# alternatives.
|
33
|
-
#
|
34
|
-
# NOTE: if a system has (for example) chkconfig installed then we
|
35
|
-
# should report that chkconfig is installed. The fact that a system
|
36
|
-
# may also have systemd installed does not mean that we do not
|
37
|
-
# report that systemd is also installed. This module is purely for
|
38
|
-
# discovery of all the alternatives, handling the priority of the
|
39
|
-
# different services is NOT a design concern of this module.
|
40
|
-
#
|
41
27
|
def service_resource_providers
|
42
28
|
providers = []
|
43
29
|
|
44
|
-
if
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
if
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
if file_exist?(Chef.path_to("/sbin/initctl"))
|
53
|
-
providers << :upstart
|
54
|
-
end
|
55
|
-
|
56
|
-
if file_exist?(Chef.path_to("/sbin/insserv"))
|
57
|
-
providers << :insserv
|
58
|
-
end
|
59
|
-
|
60
|
-
if systemd_is_init?
|
61
|
-
providers << :systemd
|
62
|
-
end
|
63
|
-
|
64
|
-
if file_exist?(Chef.path_to("/sbin/chkconfig"))
|
65
|
-
providers << :redhat
|
66
|
-
end
|
30
|
+
providers << :debian if ChefUtils::DSL::Service.debianrcd?
|
31
|
+
providers << :invokercd if ChefUtils::DSL::Service.invokercd?
|
32
|
+
providers << :upstart if ChefUtils::DSL::Service.upstart?
|
33
|
+
providers << :insserv if ChefUtils::DSL::Service.insserv?
|
34
|
+
providers << :systemd if ChefUtils.systemd?
|
35
|
+
providers << :redhat if ChefUtils::DSL::Service.redhatrcd?
|
67
36
|
|
68
37
|
providers
|
69
38
|
end
|
@@ -71,54 +40,14 @@ class Chef
|
|
71
40
|
def config_for_service(service_name)
|
72
41
|
configs = []
|
73
42
|
|
74
|
-
if
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
if
|
79
|
-
configs << :upstart
|
80
|
-
end
|
81
|
-
|
82
|
-
if file_exist?(Chef.path_to("/etc/xinetd.d/#{service_name}"))
|
83
|
-
configs << :xinetd
|
84
|
-
end
|
85
|
-
|
86
|
-
if file_exist?(Chef.path_to("/etc/rc.d/#{service_name}"))
|
87
|
-
configs << :etc_rcd
|
88
|
-
end
|
89
|
-
|
90
|
-
if file_exist?(Chef.path_to("/usr/local/etc/rc.d/#{service_name}"))
|
91
|
-
configs << :usr_local_etc_rcd
|
92
|
-
end
|
93
|
-
|
94
|
-
if has_systemd_service_unit?(service_name) || has_systemd_unit?(service_name)
|
95
|
-
configs << :systemd
|
96
|
-
end
|
43
|
+
configs << :initd if ChefUtils::DSL::Service.service_script_exist?(:initd, service_name)
|
44
|
+
configs << :upstart if ChefUtils::DSL::Service.service_script_exist?(:upstart, service_name)
|
45
|
+
configs << :xinetd if ChefUtils::DSL::Service.service_script_exist?(:xinetd, service_name)
|
46
|
+
configs << :systemd if ChefUtils::DSL::Service.service_script_exist?(:systemd, service_name)
|
47
|
+
configs << :etc_rcd if ChefUtils::DSL::Service.service_script_exist?(:etc_rcd, service_name)
|
97
48
|
|
98
49
|
configs
|
99
50
|
end
|
100
|
-
|
101
|
-
private
|
102
|
-
|
103
|
-
def systemd_is_init?
|
104
|
-
file_exist?(Chef.path_to("/proc/1/comm")) &&
|
105
|
-
file_open(Chef.path_to("/proc/1/comm")).gets.chomp == "systemd"
|
106
|
-
end
|
107
|
-
|
108
|
-
def has_systemd_service_unit?(svc_name)
|
109
|
-
%w{ /etc /usr/lib /lib /run }.any? do |load_path|
|
110
|
-
file_exist?(
|
111
|
-
Chef.path_to("#{load_path}/systemd/system/#{svc_name.gsub(/@.*$/, "@")}.service")
|
112
|
-
)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def has_systemd_unit?(svc_name)
|
117
|
-
# TODO: stop supporting non-service units with service resource
|
118
|
-
%w{ /etc /usr/lib /lib /run }.any? do |load_path|
|
119
|
-
file_exist?(Chef.path_to("#{load_path}/systemd/system/#{svc_name}"))
|
120
|
-
end
|
121
|
-
end
|
122
51
|
end
|
123
52
|
end
|
124
53
|
end
|
data/lib/chef/provider.rb
CHANGED
@@ -46,6 +46,8 @@ class Chef
|
|
46
46
|
|
47
47
|
# includes the "core" DSL and not the "recipe" DSL by design
|
48
48
|
include Chef::DSL::Core
|
49
|
+
# the class only gets the Universal DSL (no resource_collection at class parsing time)
|
50
|
+
extend Chef::DSL::Universal
|
49
51
|
|
50
52
|
# supports the given resource and action (late binding)
|
51
53
|
def self.supports?(resource, action)
|
data/lib/chef/provider/file.rb
CHANGED
@@ -84,7 +84,7 @@ class Chef
|
|
84
84
|
end
|
85
85
|
|
86
86
|
# true if we are going to be creating a new file
|
87
|
-
@needs_creating
|
87
|
+
@needs_creating = !::File.exist?(new_resource.path) || needs_unlinking?
|
88
88
|
|
89
89
|
# Let children resources override constructing the current_resource
|
90
90
|
@current_resource ||= Chef::Resource::File.new(new_resource.name)
|
@@ -453,7 +453,7 @@ class Chef
|
|
453
453
|
end
|
454
454
|
|
455
455
|
def load_resource_attributes_from_file(resource)
|
456
|
-
if
|
456
|
+
if ChefUtils.windows?
|
457
457
|
# This is a work around for CHEF-3554.
|
458
458
|
# OC-6534: is tracking the real fix for this workaround.
|
459
459
|
# Add support for Windows equivalent, or implicit resource
|
@@ -22,7 +22,7 @@ class Chef
|
|
22
22
|
class Provider
|
23
23
|
class Ifconfig
|
24
24
|
class Redhat < Chef::Provider::Ifconfig
|
25
|
-
provides :ifconfig, platform_family:
|
25
|
+
provides :ifconfig, platform_family: "fedora_derived"
|
26
26
|
|
27
27
|
def initialize(new_resource, run_context)
|
28
28
|
super(new_resource, run_context)
|
data/lib/chef/provider/link.rb
CHANGED
@@ -82,7 +82,7 @@ class Chef
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def canonicalize(path)
|
85
|
-
|
85
|
+
ChefUtils.windows? ? path.tr("/", '\\') : path
|
86
86
|
end
|
87
87
|
|
88
88
|
def action_create
|
@@ -101,7 +101,7 @@ class Chef
|
|
101
101
|
# However if the new symlink will point to a file and the current symlink is pointing at a
|
102
102
|
# directory we want to throw an exception and calling ::File.unlink on the directory symlink
|
103
103
|
# will throw the correct ones.
|
104
|
-
if
|
104
|
+
if ChefUtils.windows? && ::File.directory?(new_resource.to) &&
|
105
105
|
::File.directory?(current_resource.target_file)
|
106
106
|
converge_by("unlink existing windows symlink to dir at #{new_resource.target_file}") do
|
107
107
|
::Dir.unlink(new_resource.target_file)
|
@@ -143,7 +143,7 @@ class Chef
|
|
143
143
|
|
144
144
|
def action_delete
|
145
145
|
if current_resource.to # Exists
|
146
|
-
if
|
146
|
+
if ChefUtils.windows? && ::File.directory?(current_resource.target_file)
|
147
147
|
converge_by("delete link to dir at #{new_resource.target_file}") do
|
148
148
|
::Dir.delete(new_resource.target_file)
|
149
149
|
logger.info("#{new_resource} deleted")
|
@@ -27,7 +27,7 @@ class Chef
|
|
27
27
|
class Mount
|
28
28
|
# Mount Solaris File systems
|
29
29
|
class Solaris < Chef::Provider::Mount
|
30
|
-
provides :mount,
|
30
|
+
provides :mount, platform_family: "solaris_based"
|
31
31
|
|
32
32
|
extend Forwardable
|
33
33
|
|
@@ -36,7 +36,7 @@ class Chef
|
|
36
36
|
include Chef::Mixin::Checksum
|
37
37
|
|
38
38
|
def running_on_windows!
|
39
|
-
unless
|
39
|
+
unless ChefUtils.windows?
|
40
40
|
raise Chef::Exceptions::Win32NotWindows, "Attempt to manipulate the windows registry on a non-windows node"
|
41
41
|
end
|
42
42
|
end
|
@@ -111,7 +111,7 @@ class Chef
|
|
111
111
|
next if managed_files.include?(file)
|
112
112
|
|
113
113
|
if ::File.directory?(file)
|
114
|
-
if !
|
114
|
+
if !ChefUtils.windows? && file_class.symlink?(file.dup)
|
115
115
|
# Unix treats dir symlinks as files
|
116
116
|
purge_file(file)
|
117
117
|
else
|
@@ -208,7 +208,7 @@ class Chef
|
|
208
208
|
# Set the sensitivity level
|
209
209
|
res.sensitive(new_resource.sensitive)
|
210
210
|
res.source(::File.join(source, relative_source_path))
|
211
|
-
if
|
211
|
+
if ChefUtils.windows? && files_rights
|
212
212
|
files_rights.each_pair do |permission, *args|
|
213
213
|
res.rights(permission, *args)
|
214
214
|
end
|
@@ -244,7 +244,7 @@ class Chef
|
|
244
244
|
def directory_resource(dir)
|
245
245
|
res = Chef::Resource::Directory.new(dir, run_context)
|
246
246
|
res.cookbook_name = resource_cookbook
|
247
|
-
if
|
247
|
+
if ChefUtils.windows? && rights
|
248
248
|
# rights are only meant to be applied to the toppest-level directory;
|
249
249
|
# Windows will handle inheritance.
|
250
250
|
if dir == path
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Jesse Campbell (<hikeit@gmail.com>)
|
3
3
|
# Author:: Lamont Granquist (<lamont@chef.io>)
|
4
|
-
# Copyright:: Copyright 2013-
|
4
|
+
# Copyright:: Copyright 2013-2019, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -24,7 +24,7 @@ class Chef
|
|
24
24
|
|
25
25
|
def self.for_resource(uri, new_resource, current_resource)
|
26
26
|
if network_share?(uri)
|
27
|
-
unless
|
27
|
+
unless ChefUtils.windows?
|
28
28
|
raise Exceptions::UnsupportedPlatform, "Fetching the file on a network share is supported only on the Windows platform. Please change your source: #{uri}"
|
29
29
|
end
|
30
30
|
|
data/lib/chef/provider/script.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
require "tempfile" unless defined?(Tempfile)
|
20
20
|
require_relative "execute"
|
21
|
-
require_relative "../win32/security" if
|
21
|
+
require_relative "../win32/security" if ChefUtils.windows?
|
22
22
|
require "forwardable" unless defined?(Forwardable)
|
23
23
|
|
24
24
|
class Chef
|
@@ -63,7 +63,7 @@ class Chef
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def set_owner_and_group
|
66
|
-
if
|
66
|
+
if ChefUtils.windows?
|
67
67
|
# And on Windows also this is a no-op if there is no user specified.
|
68
68
|
grant_alternate_user_read_access
|
69
69
|
else
|