chef 15.4.45 → 15.5.9
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/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 +32 -8
- data/lib/chef/mixin/train_helpers.rb +0 -60
- data/spec/unit/mash_spec.rb +0 -51
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
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: AJ Christensen (<aj@hjksolutions.com>)
|
3
3
|
# Author:: Davide Cavalca (<dcavalca@fb.com>)
|
4
|
-
# Copyright:: Copyright 2008-
|
4
|
+
# Copyright:: Copyright 2008-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");
|
@@ -18,10 +18,13 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require_relative "../provider"
|
21
|
+
require "chef-utils" unless defined?(ChefUtils::CANARY)
|
21
22
|
|
22
23
|
class Chef
|
23
24
|
class Provider
|
24
25
|
class Service < Chef::Provider
|
26
|
+
include ChefUtils::DSL::Service
|
27
|
+
extend ChefUtils::DSL::Service
|
25
28
|
|
26
29
|
def supports
|
27
30
|
@supports ||= new_resource.supports.dup
|
@@ -245,7 +248,7 @@ class Chef
|
|
245
248
|
Chef.set_provider_priority_array :service, [ Systemd, Arch ], platform_family: "arch"
|
246
249
|
Chef.set_provider_priority_array :service, [ Systemd, Gentoo ], platform_family: "gentoo"
|
247
250
|
Chef.set_provider_priority_array :service, [ Systemd, Upstart, Insserv, Debian, Invokercd ], platform_family: "debian"
|
248
|
-
Chef.set_provider_priority_array :service, [ Systemd, Insserv, Redhat ], platform_family:
|
251
|
+
Chef.set_provider_priority_array :service, [ Systemd, Insserv, Redhat ], platform_family: "rpm_based"
|
249
252
|
end
|
250
253
|
end
|
251
254
|
end
|
@@ -23,7 +23,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
|
|
23
23
|
provides :service, platform_family: "arch"
|
24
24
|
|
25
25
|
def self.supports?(resource, action)
|
26
|
-
|
26
|
+
service_script_exist?(:etc_rcd, resource.service_name)
|
27
27
|
end
|
28
28
|
|
29
29
|
def initialize(new_resource, run_context)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: AJ Christensen (<aj@hjksolutions.com>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2018, 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");
|
@@ -22,15 +22,15 @@ class Chef
|
|
22
22
|
class Provider
|
23
23
|
class Service
|
24
24
|
class Debian < Chef::Provider::Service::Init
|
25
|
-
provides :service, platform_family: "debian" do
|
26
|
-
|
25
|
+
provides :service, platform_family: "debian" do
|
26
|
+
debianrcd?
|
27
27
|
end
|
28
28
|
|
29
29
|
UPDATE_RC_D_ENABLED_MATCHES = %r{/rc[\dS].d/S|not installed}i.freeze
|
30
30
|
UPDATE_RC_D_PRIORITIES = %r{/rc([\dS]).d/([SK])(\d\d)}i.freeze
|
31
31
|
|
32
32
|
def self.supports?(resource, action)
|
33
|
-
|
33
|
+
service_script_exist?(:initd, resource.service_name)
|
34
34
|
end
|
35
35
|
|
36
36
|
def load_current_resource
|
@@ -29,7 +29,7 @@ class Chef
|
|
29
29
|
provides :service, os: "!windows"
|
30
30
|
|
31
31
|
def self.supports?(resource, action)
|
32
|
-
|
32
|
+
service_script_exist?(:initd, resource.service_name)
|
33
33
|
end
|
34
34
|
|
35
35
|
def initialize(new_resource, run_context)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Bryan McLellan <btm@loftninjas.org>
|
3
|
-
# Copyright:: Copyright 2011-
|
3
|
+
# Copyright:: Copyright 2011-2018, 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");
|
@@ -24,12 +24,12 @@ class Chef
|
|
24
24
|
class Service
|
25
25
|
class Insserv < Chef::Provider::Service::Init
|
26
26
|
|
27
|
-
provides :service, platform_family: %w{debian rhel fedora suse amazon} do
|
28
|
-
|
27
|
+
provides :service, platform_family: %w{debian rhel fedora suse amazon} do
|
28
|
+
insserv?
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.supports?(resource, action)
|
32
|
-
|
32
|
+
service_script_exist?(:initd, resource.service_name)
|
33
33
|
end
|
34
34
|
|
35
35
|
def load_current_resource
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: AJ Christensen (<aj@hjksolutions.com>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2018, 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");
|
@@ -23,12 +23,12 @@ class Chef
|
|
23
23
|
class Service
|
24
24
|
class Invokercd < Chef::Provider::Service::Init
|
25
25
|
|
26
|
-
provides :service, platform_family: "debian", override: true do
|
27
|
-
|
26
|
+
provides :service, platform_family: "debian", override: true do
|
27
|
+
invokercd?
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.supports?(resource, action)
|
31
|
-
|
31
|
+
service_script_exist?(:initd, resource.service_name)
|
32
32
|
end
|
33
33
|
|
34
34
|
def initialize(new_resource, run_context)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: AJ Christensen (<aj@hjksolutions.com>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2018, 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");
|
@@ -28,15 +28,15 @@ class Chef
|
|
28
28
|
# @api private
|
29
29
|
attr_accessor :current_run_levels
|
30
30
|
|
31
|
-
provides :service, platform_family:
|
32
|
-
|
31
|
+
provides :service, platform_family: "rpm_based" do
|
32
|
+
redhatrcd?
|
33
33
|
end
|
34
34
|
|
35
35
|
CHKCONFIG_ON = /\d:on/.freeze
|
36
36
|
CHKCONFIG_MISSING = /No such/.freeze
|
37
37
|
|
38
38
|
def self.supports?(resource, action)
|
39
|
-
|
39
|
+
service_script_exist?(:initd, resource.service_name)
|
40
40
|
end
|
41
41
|
|
42
42
|
def initialize(new_resource, run_context)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Stephen Haynes (<sh@nomitor.com>)
|
3
3
|
# Author:: Davide Cavalca (<dcavalca@fb.com>)
|
4
|
-
# Copyright:: Copyright 2011-
|
4
|
+
# Copyright:: Copyright 2011-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");
|
@@ -27,13 +27,13 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
27
27
|
include Chef::Mixin::Which
|
28
28
|
|
29
29
|
provides :service, os: "linux", target_mode: true do |node|
|
30
|
-
|
30
|
+
systemd?
|
31
31
|
end
|
32
32
|
|
33
33
|
attr_accessor :status_check_success
|
34
34
|
|
35
35
|
def self.supports?(resource, action)
|
36
|
-
|
36
|
+
service_script_exist?(:systemd, resource.service_name)
|
37
37
|
end
|
38
38
|
|
39
39
|
def load_current_resource
|
@@ -51,6 +51,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
51
51
|
current_resource.running(false)
|
52
52
|
current_resource.enabled(false)
|
53
53
|
current_resource.masked(false)
|
54
|
+
current_resource.indirect(false)
|
54
55
|
end
|
55
56
|
else
|
56
57
|
current_resource.running(is_active?)
|
@@ -58,6 +59,7 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
58
59
|
|
59
60
|
current_resource.enabled(is_enabled?)
|
60
61
|
current_resource.masked(is_masked?)
|
62
|
+
current_resource.indirect(is_indirect?)
|
61
63
|
current_resource
|
62
64
|
end
|
63
65
|
|
@@ -143,11 +145,19 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
143
145
|
end
|
144
146
|
|
145
147
|
def enable_service
|
148
|
+
if current_resource.masked || current_resource.indirect
|
149
|
+
logger.trace("#{new_resource} cannot be enabled: it is masked or indirect")
|
150
|
+
return
|
151
|
+
end
|
146
152
|
options, args = get_systemctl_options_args
|
147
153
|
shell_out!("#{systemctl_path} #{args} enable #{Shellwords.escape(new_resource.service_name)}", **options)
|
148
154
|
end
|
149
155
|
|
150
156
|
def disable_service
|
157
|
+
if current_resource.masked || current_resource.indirect
|
158
|
+
logger.trace("#{new_resource} cannot be disabled: it is masked or indirect")
|
159
|
+
return
|
160
|
+
end
|
151
161
|
options, args = get_systemctl_options_args
|
152
162
|
shell_out!("#{systemctl_path} #{args} disable #{Shellwords.escape(new_resource.service_name)}", **options)
|
153
163
|
end
|
@@ -172,6 +182,12 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
|
|
172
182
|
shell_out("#{systemctl_path} #{args} is-enabled #{Shellwords.escape(new_resource.service_name)} --quiet", **options).exitstatus == 0
|
173
183
|
end
|
174
184
|
|
185
|
+
def is_indirect?
|
186
|
+
options, args = get_systemctl_options_args
|
187
|
+
s = shell_out("#{systemctl_path} #{args} is-enabled #{Shellwords.escape(new_resource.service_name)}", **options)
|
188
|
+
s.stdout.include?("indirect")
|
189
|
+
end
|
190
|
+
|
175
191
|
def is_masked?
|
176
192
|
options, args = get_systemctl_options_args
|
177
193
|
s = shell_out("#{systemctl_path} #{args} is-enabled #{Shellwords.escape(new_resource.service_name)}", **options)
|
@@ -28,15 +28,15 @@ class Chef
|
|
28
28
|
# to maintain a local state of service across restart's internal calls
|
29
29
|
attr_accessor :upstart_service_running
|
30
30
|
|
31
|
-
provides :service, platform_family: "debian", override: true do
|
32
|
-
|
31
|
+
provides :service, platform_family: "debian", override: true do
|
32
|
+
upstart?
|
33
33
|
end
|
34
34
|
|
35
35
|
UPSTART_STATE_FORMAT = %r{\S+ \(?(start|stop)?\)? ?[/ ](\w+)}.freeze
|
36
36
|
|
37
37
|
# Returns true if the configs for the service name has upstart variable
|
38
38
|
def self.supports?(resource, action)
|
39
|
-
|
39
|
+
service_script_exist?(:upstart, resource.service_name)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Upstart does more than start or stop a service, creating multiple 'states' [1] that a service can be in.
|
@@ -42,6 +42,7 @@ class Chef
|
|
42
42
|
current_resource.active(active?)
|
43
43
|
current_resource.masked(masked?)
|
44
44
|
current_resource.static(static?)
|
45
|
+
current_resource.indirect(indirect?)
|
45
46
|
current_resource.triggers_reload(new_resource.triggers_reload)
|
46
47
|
|
47
48
|
current_resource
|
@@ -90,10 +91,14 @@ class Chef
|
|
90
91
|
if current_resource.static
|
91
92
|
logger.trace("#{new_resource.unit_name} is a static unit, enabling is a NOP.")
|
92
93
|
end
|
94
|
+
if current_resource.indirect
|
95
|
+
logger.trace("#{new_resource.unit_name} is an indirect unit, enabling is a NOP.")
|
96
|
+
end
|
93
97
|
|
94
|
-
unless current_resource.enabled || current_resource.static
|
98
|
+
unless current_resource.enabled || current_resource.static || current_resource.indirect
|
95
99
|
converge_by("enabling unit: #{new_resource.unit_name}") do
|
96
100
|
systemctl_execute!(:enable, new_resource.unit_name)
|
101
|
+
logger.info("#{new_resource} enabled")
|
97
102
|
end
|
98
103
|
end
|
99
104
|
end
|
@@ -103,9 +108,14 @@ class Chef
|
|
103
108
|
logger.trace("#{new_resource.unit_name} is a static unit, disabling is a NOP.")
|
104
109
|
end
|
105
110
|
|
106
|
-
if current_resource.
|
111
|
+
if current_resource.indirect
|
112
|
+
logger.trace("#{new_resource.unit_name} is an indirect unit, enabling is a NOP.")
|
113
|
+
end
|
114
|
+
|
115
|
+
if current_resource.enabled && !current_resource.static && !current_resource.indirect
|
107
116
|
converge_by("disabling unit: #{new_resource.unit_name}") do
|
108
117
|
systemctl_execute!(:disable, new_resource.unit_name)
|
118
|
+
logger.info("#{new_resource} disabled")
|
109
119
|
end
|
110
120
|
end
|
111
121
|
end
|
@@ -113,6 +123,7 @@ class Chef
|
|
113
123
|
def action_reenable
|
114
124
|
converge_by("reenabling unit: #{new_resource.unit_name}") do
|
115
125
|
systemctl_execute!(:reenable, new_resource.unit_name)
|
126
|
+
logger.info("#{new_resource} reenabled")
|
116
127
|
end
|
117
128
|
end
|
118
129
|
|
@@ -120,6 +131,7 @@ class Chef
|
|
120
131
|
unless current_resource.masked
|
121
132
|
converge_by("masking unit: #{new_resource.unit_name}") do
|
122
133
|
systemctl_execute!(:mask, new_resource.unit_name)
|
134
|
+
logger.info("#{new_resource} masked")
|
123
135
|
end
|
124
136
|
end
|
125
137
|
end
|
@@ -128,6 +140,7 @@ class Chef
|
|
128
140
|
if current_resource.masked
|
129
141
|
converge_by("unmasking unit: #{new_resource.unit_name}") do
|
130
142
|
systemctl_execute!(:unmask, new_resource.unit_name)
|
143
|
+
logger.info("#{new_resource} unmasked")
|
131
144
|
end
|
132
145
|
end
|
133
146
|
end
|
@@ -136,6 +149,7 @@ class Chef
|
|
136
149
|
unless current_resource.active
|
137
150
|
converge_by("starting unit: #{new_resource.unit_name}") do
|
138
151
|
systemctl_execute!(:start, new_resource.unit_name, default_env: false)
|
152
|
+
logger.info("#{new_resource} started")
|
139
153
|
end
|
140
154
|
end
|
141
155
|
end
|
@@ -144,6 +158,7 @@ class Chef
|
|
144
158
|
if current_resource.active
|
145
159
|
converge_by("stopping unit: #{new_resource.unit_name}") do
|
146
160
|
systemctl_execute!(:stop, new_resource.unit_name, default_env: false)
|
161
|
+
logger.info("#{new_resource} stopped")
|
147
162
|
end
|
148
163
|
end
|
149
164
|
end
|
@@ -151,6 +166,7 @@ class Chef
|
|
151
166
|
def action_restart
|
152
167
|
converge_by("restarting unit: #{new_resource.unit_name}") do
|
153
168
|
systemctl_execute!(:restart, new_resource.unit_name, default_env: false)
|
169
|
+
logger.info("#{new_resource} restarted")
|
154
170
|
end
|
155
171
|
end
|
156
172
|
|
@@ -158,6 +174,7 @@ class Chef
|
|
158
174
|
if current_resource.active
|
159
175
|
converge_by("reloading unit: #{new_resource.unit_name}") do
|
160
176
|
systemctl_execute!(:reload, new_resource.unit_name, default_env: false)
|
177
|
+
logger.info("#{new_resource} reloaded")
|
161
178
|
end
|
162
179
|
else
|
163
180
|
logger.trace("#{new_resource.unit_name} is not active, skipping reload.")
|
@@ -167,18 +184,21 @@ class Chef
|
|
167
184
|
def action_try_restart
|
168
185
|
converge_by("try-restarting unit: #{new_resource.unit_name}") do
|
169
186
|
systemctl_execute!("try-restart", new_resource.unit_name, default_env: false)
|
187
|
+
logger.info("#{new_resource} try-restarted")
|
170
188
|
end
|
171
189
|
end
|
172
190
|
|
173
191
|
def action_reload_or_restart
|
174
192
|
converge_by("reload-or-restarting unit: #{new_resource.unit_name}") do
|
175
193
|
systemctl_execute!("reload-or-restart", new_resource.unit_name, default_env: false)
|
194
|
+
logger.info("#{new_resource} reload-or-restarted")
|
176
195
|
end
|
177
196
|
end
|
178
197
|
|
179
198
|
def action_reload_or_try_restart
|
180
199
|
converge_by("reload-or-try-restarting unit: #{new_resource.unit_name}") do
|
181
200
|
systemctl_execute!("reload-or-try-restart", new_resource.unit_name, default_env: false)
|
201
|
+
logger.info("#{new_resource} reload-or-try-restarted")
|
182
202
|
end
|
183
203
|
end
|
184
204
|
|
@@ -198,6 +218,10 @@ class Chef
|
|
198
218
|
systemctl_execute("is-enabled", new_resource.unit_name).stdout.include?("static")
|
199
219
|
end
|
200
220
|
|
221
|
+
def indirect?
|
222
|
+
systemctl_execute("is-enabled", new_resource.unit_name).stdout.include?("indirect")
|
223
|
+
end
|
224
|
+
|
201
225
|
private
|
202
226
|
|
203
227
|
def unit_path
|