summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/file.rb2
-rw-r--r--lib/chef/provider/ifconfig/redhat.rb2
-rw-r--r--lib/chef/provider/link.rb6
-rw-r--r--lib/chef/provider/mount/solaris.rb2
-rw-r--r--lib/chef/provider/package/yum.rb2
-rw-r--r--lib/chef/provider/registry_key.rb2
-rw-r--r--lib/chef/provider/remote_directory.rb6
-rw-r--r--lib/chef/provider/remote_file/fetcher.rb2
-rw-r--r--lib/chef/provider/remote_file/local_file.rb2
-rw-r--r--lib/chef/provider/script.rb4
-rw-r--r--lib/chef/provider/service.rb7
-rw-r--r--lib/chef/provider/service/arch.rb2
-rw-r--r--lib/chef/provider/service/debian.rb8
-rw-r--r--lib/chef/provider/service/init.rb2
-rw-r--r--lib/chef/provider/service/insserv.rb8
-rw-r--r--lib/chef/provider/service/invokercd.rb8
-rw-r--r--lib/chef/provider/service/redhat.rb8
-rw-r--r--lib/chef/provider/service/systemd.rb6
-rw-r--r--lib/chef/provider/service/upstart.rb6
-rw-r--r--lib/chef/provider/subversion.rb2
-rw-r--r--lib/chef/provider/windows_path.rb4
-rw-r--r--lib/chef/provider/windows_task.rb4
22 files changed, 49 insertions, 46 deletions
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index 05522f1eb8..e7793a04aa 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -451,7 +451,7 @@ class Chef
end
def load_resource_attributes_from_file(resource)
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
# This is a work around for CHEF-3554.
# OC-6534: is tracking the real fix for this workaround.
# Add support for Windows equivalent, or implicit resource
diff --git a/lib/chef/provider/ifconfig/redhat.rb b/lib/chef/provider/ifconfig/redhat.rb
index 70d78bcfe9..275207665b 100644
--- a/lib/chef/provider/ifconfig/redhat.rb
+++ b/lib/chef/provider/ifconfig/redhat.rb
@@ -22,7 +22,7 @@ class Chef
class Provider
class Ifconfig
class Redhat < Chef::Provider::Ifconfig
- provides :ifconfig, platform_family: %w{fedora rhel amazon}
+ provides :ifconfig, platform_family: "fedora_derived"
def initialize(new_resource, run_context)
super(new_resource, run_context)
diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb
index 783d52d09a..b2ab2515d7 100644
--- a/lib/chef/provider/link.rb
+++ b/lib/chef/provider/link.rb
@@ -82,7 +82,7 @@ class Chef
end
def canonicalize(path)
- Chef::Platform.windows? ? path.tr("/", '\\') : path
+ ChefHelpers.windows? ? path.tr("/", '\\') : path
end
def action_create
@@ -101,7 +101,7 @@ class Chef
# However if the new symlink will point to a file and the current symlink is pointing at a
# directory we want to throw an exception and calling ::File.unlink on the directory symlink
# will throw the correct ones.
- if Chef::Platform.windows? && ::File.directory?(new_resource.to) &&
+ if ChefHelpers.windows? && ::File.directory?(new_resource.to) &&
::File.directory?(current_resource.target_file)
converge_by("unlink existing windows symlink to dir at #{new_resource.target_file}") do
::Dir.unlink(new_resource.target_file)
@@ -143,7 +143,7 @@ class Chef
def action_delete
if current_resource.to # Exists
- if Chef::Platform.windows? && ::File.directory?(current_resource.target_file)
+ if ChefHelpers.windows? && ::File.directory?(current_resource.target_file)
converge_by("delete link to dir at #{new_resource.target_file}") do
::Dir.delete(new_resource.target_file)
logger.info("#{new_resource} deleted")
diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb
index 48936c8057..8f8aa77b11 100644
--- a/lib/chef/provider/mount/solaris.rb
+++ b/lib/chef/provider/mount/solaris.rb
@@ -27,7 +27,7 @@ class Chef
class Mount
# Mount Solaris File systems
class Solaris < Chef::Provider::Mount
- provides :mount, platform: %w{openindiana opensolaris nexentacore omnios solaris2 smartos}
+ provides :mount, platform_family: "solaris_based"
extend Forwardable
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index e991e4541e..4dd3cb69f4 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -37,7 +37,7 @@ class Chef
use_multipackage_api
use_package_name_for_source
- provides :package, platform_family: %w{fedora amazon rhel}
+ provides :package, platform_family: "fedora_derived"
provides :yum_package
diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb
index 7c7b190b95..e6412858ce 100644
--- a/lib/chef/provider/registry_key.rb
+++ b/lib/chef/provider/registry_key.rb
@@ -36,7 +36,7 @@ class Chef
include Chef::Mixin::Checksum
def running_on_windows!
- unless Chef::Platform.windows?
+ unless ChefHelpers.windows?
raise Chef::Exceptions::Win32NotWindows, "Attempt to manipulate the windows registry on a non-windows node"
end
end
diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb
index 94de68c557..7485a4bcbd 100644
--- a/lib/chef/provider/remote_directory.rb
+++ b/lib/chef/provider/remote_directory.rb
@@ -111,7 +111,7 @@ class Chef
next if managed_files.include?(file)
if ::File.directory?(file)
- if !Chef::Platform.windows? && file_class.symlink?(file.dup)
+ if !ChefHelpers.windows? && file_class.symlink?(file.dup)
# Unix treats dir symlinks as files
purge_file(file)
else
@@ -208,7 +208,7 @@ class Chef
# Set the sensitivity level
res.sensitive(new_resource.sensitive)
res.source(::File.join(source, relative_source_path))
- if Chef::Platform.windows? && files_rights
+ if ChefHelpers.windows? && files_rights
files_rights.each_pair do |permission, *args|
res.rights(permission, *args)
end
@@ -244,7 +244,7 @@ class Chef
def directory_resource(dir)
res = Chef::Resource::Directory.new(dir, run_context)
res.cookbook_name = resource_cookbook
- if Chef::Platform.windows? && rights
+ if ChefHelpers.windows? && rights
# rights are only meant to be applied to the toppest-level directory;
# Windows will handle inheritance.
if dir == path
diff --git a/lib/chef/provider/remote_file/fetcher.rb b/lib/chef/provider/remote_file/fetcher.rb
index 3011dd80a0..5b3e256d24 100644
--- a/lib/chef/provider/remote_file/fetcher.rb
+++ b/lib/chef/provider/remote_file/fetcher.rb
@@ -24,7 +24,7 @@ class Chef
def self.for_resource(uri, new_resource, current_resource)
if network_share?(uri)
- if !Chef::Platform.windows?
+ if !ChefHelpers.windows?
raise Exceptions::UnsupportedPlatform, "Fetching the file on a network share is supported only on the Windows platform. Please change your source: #{uri}"
end
Chef::Provider::RemoteFile::NetworkFile.new(uri, new_resource, current_resource)
diff --git a/lib/chef/provider/remote_file/local_file.rb b/lib/chef/provider/remote_file/local_file.rb
index 0719e5dbf7..e8a521763d 100644
--- a/lib/chef/provider/remote_file/local_file.rb
+++ b/lib/chef/provider/remote_file/local_file.rb
@@ -41,7 +41,7 @@ class Chef
def source_path
@source_path ||= begin
path = URI.unescape(uri.path)
- Chef::Platform.windows? ? fix_windows_path(path) : path
+ ChefHelpers.windows? ? fix_windows_path(path) : path
end
end
diff --git a/lib/chef/provider/script.rb b/lib/chef/provider/script.rb
index c5966370f7..3c0431e928 100644
--- a/lib/chef/provider/script.rb
+++ b/lib/chef/provider/script.rb
@@ -18,7 +18,7 @@
require "tempfile"
require "chef/provider/execute"
-require "chef/win32/security" if Chef::Platform.windows?
+require "chef/win32/security" if ChefHelpers.windows?
require "forwardable"
class Chef
@@ -67,7 +67,7 @@ class Chef
end
def set_owner_and_group
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
# And on Windows also this is a no-op if there is no user specified.
grant_alternate_user_read_access
else
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
index c116d321f1..4d3d640866 100644
--- a/lib/chef/provider/service.rb
+++ b/lib/chef/provider/service.rb
@@ -1,7 +1,7 @@
#
# Author:: AJ Christensen (<aj@hjksolutions.com>)
# Author:: Davide Cavalca (<dcavalca@fb.com>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,10 +18,13 @@
#
require "chef/provider"
+require "chef-helpers"
class Chef
class Provider
class Service < Chef::Provider
+ include ChefHelpers::Service
+ extend ChefHelpers::Service
def supports
@supports ||= new_resource.supports.dup
@@ -245,7 +248,7 @@ class Chef
Chef.set_provider_priority_array :service, [ Systemd, Arch ], platform_family: "arch"
Chef.set_provider_priority_array :service, [ Systemd, Gentoo ], platform_family: "gentoo"
Chef.set_provider_priority_array :service, [ Systemd, Upstart, Insserv, Debian, Invokercd ], platform_family: "debian"
- Chef.set_provider_priority_array :service, [ Systemd, Insserv, Redhat ], platform_family: %w{rhel fedora suse amazon}
+ Chef.set_provider_priority_array :service, [ Systemd, Insserv, Redhat ], platform_family: "rpm_based"
end
end
end
diff --git a/lib/chef/provider/service/arch.rb b/lib/chef/provider/service/arch.rb
index e34227036a..da1c71ba8b 100644
--- a/lib/chef/provider/service/arch.rb
+++ b/lib/chef/provider/service/arch.rb
@@ -23,7 +23,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init
provides :service, platform_family: "arch"
def self.supports?(resource, action)
- Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:etc_rcd)
+ service_script_exist?(:etc_rcd, resource.service_name)
end
def initialize(new_resource, run_context)
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
index 351075111b..61cae7421b 100644
--- a/lib/chef/provider/service/debian.rb
+++ b/lib/chef/provider/service/debian.rb
@@ -1,6 +1,6 @@
#
# Author:: AJ Christensen (<aj@hjksolutions.com>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,15 +22,15 @@ class Chef
class Provider
class Service
class Debian < Chef::Provider::Service::Init
- provides :service, platform_family: "debian" do |node|
- Chef::Platform::ServiceHelpers.service_resource_providers.include?(:debian)
+ provides :service, platform_family: "debian" do
+ debianrcd?
end
UPDATE_RC_D_ENABLED_MATCHES = /\/rc[\dS].d\/S|not installed/i
UPDATE_RC_D_PRIORITIES = /\/rc([\dS]).d\/([SK])(\d\d)/i
def self.supports?(resource, action)
- Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
+ service_script_exist?(:initd, resource.service_name)
end
def load_current_resource
diff --git a/lib/chef/provider/service/init.rb b/lib/chef/provider/service/init.rb
index 6d150513cc..55f2d7d509 100644
--- a/lib/chef/provider/service/init.rb
+++ b/lib/chef/provider/service/init.rb
@@ -29,7 +29,7 @@ class Chef
provides :service, os: "!windows"
def self.supports?(resource, action)
- Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
+ service_script_exist?(:initd, resource.service_name)
end
def initialize(new_resource, run_context)
diff --git a/lib/chef/provider/service/insserv.rb b/lib/chef/provider/service/insserv.rb
index a8e841f8b3..2ea9dbd340 100644
--- a/lib/chef/provider/service/insserv.rb
+++ b/lib/chef/provider/service/insserv.rb
@@ -1,6 +1,6 @@
#
# Author:: Bryan McLellan <btm@loftninjas.org>
-# Copyright:: Copyright 2011-2017, Chef Software Inc.
+# Copyright:: Copyright 2011-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,12 +24,12 @@ class Chef
class Service
class Insserv < Chef::Provider::Service::Init
- provides :service, platform_family: %w{debian rhel fedora suse amazon} do |node|
- Chef::Platform::ServiceHelpers.service_resource_providers.include?(:insserv)
+ provides :service, platform_family: %w{debian rhel fedora suse amazon} do
+ insserv?
end
def self.supports?(resource, action)
- Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
+ service_script_exist?(:initd, resource.service_name)
end
def load_current_resource
diff --git a/lib/chef/provider/service/invokercd.rb b/lib/chef/provider/service/invokercd.rb
index 9477afec48..08c9f0ebc3 100644
--- a/lib/chef/provider/service/invokercd.rb
+++ b/lib/chef/provider/service/invokercd.rb
@@ -1,6 +1,6 @@
#
# Author:: AJ Christensen (<aj@hjksolutions.com>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,12 +23,12 @@ class Chef
class Service
class Invokercd < Chef::Provider::Service::Init
- provides :service, platform_family: "debian", override: true do |node|
- Chef::Platform::ServiceHelpers.service_resource_providers.include?(:invokercd)
+ provides :service, platform_family: "debian", override: true do
+ invokercd?
end
def self.supports?(resource, action)
- Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
+ service_script_exist?(:initd, resource.service_name)
end
def initialize(new_resource, run_context)
diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb
index 18ef245083..77b83aae1f 100644
--- a/lib/chef/provider/service/redhat.rb
+++ b/lib/chef/provider/service/redhat.rb
@@ -1,6 +1,6 @@
#
# Author:: AJ Christensen (<aj@hjksolutions.com>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,15 +28,15 @@ class Chef
# @api private
attr_accessor :current_run_levels
- provides :service, platform_family: %w{rhel fedora suse amazon} do |node|
- Chef::Platform::ServiceHelpers.service_resource_providers.include?(:redhat)
+ provides :service, platform_family: "rpm_based" do
+ redhatrcd?
end
CHKCONFIG_ON = /\d:on/
CHKCONFIG_MISSING = /No such/
def self.supports?(resource, action)
- Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:initd)
+ service_script_exist?(:initd, resource.service_name)
end
def initialize(new_resource, run_context)
diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb
index 6d5bc338c7..fac4686c4f 100644
--- a/lib/chef/provider/service/systemd.rb
+++ b/lib/chef/provider/service/systemd.rb
@@ -26,14 +26,14 @@ class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple
include Chef::Mixin::Which
- provides :service, os: "linux" do |node|
- Chef::Platform::ServiceHelpers.service_resource_providers.include?(:systemd)
+ provides :service, os: "linux" do
+ systemd?
end
attr_accessor :status_check_success
def self.supports?(resource, action)
- Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:systemd)
+ service_script_exist?(:systemd, resource.service_name)
end
def load_current_resource
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 68f97d1ff2..f2ff182aa9 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -28,15 +28,15 @@ class Chef
# to maintain a local state of service across restart's internal calls
attr_accessor :upstart_service_running
- provides :service, platform_family: "debian", override: true do |node|
- Chef::Platform::ServiceHelpers.service_resource_providers.include?(:upstart)
+ provides :service, platform_family: "debian", override: true do
+ upstart?
end
UPSTART_STATE_FORMAT = /\S+ \(?(start|stop)?\)? ?[\/ ](\w+)/
# Returns true if the configs for the service name has upstart variable
def self.supports?(resource, action)
- Chef::Platform::ServiceHelpers.config_for_service(resource.service_name).include?(:upstart)
+ service_script_exist?(:upstart, resource.service_name)
end
# Upstart does more than start or stop a service, creating multiple 'states' [1] that a service can be in.
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index dec9e06f87..99886961a9 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -212,7 +212,7 @@ class Chef
def svn_binary
new_resource.svn_binary ||
- (Chef::Platform.windows? ? "svn.exe" : "svn")
+ (ChefHelpers.windows? ? "svn.exe" : "svn")
end
def assert_target_directory_valid!
diff --git a/lib/chef/provider/windows_path.rb b/lib/chef/provider/windows_path.rb
index 1c78e20606..33b37804ed 100644
--- a/lib/chef/provider/windows_path.rb
+++ b/lib/chef/provider/windows_path.rb
@@ -16,14 +16,14 @@
# limitations under the License.
#
-require "chef/mixin/windows_env_helper" if Chef::Platform.windows?
+require "chef/mixin/windows_env_helper" if ChefHelpers.windows?
require "chef/mixin/wide_string"
require "chef/exceptions"
class Chef
class Provider
class WindowsPath < Chef::Provider
- include Chef::Mixin::WindowsEnvHelper if Chef::Platform.windows?
+ include Chef::Mixin::WindowsEnvHelper if ChefHelpers.windows?
provides :windows_path
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index 98dd8795fa..eb0404f55e 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -22,7 +22,7 @@ require "iso8601"
require "chef/mixin/powershell_out"
require "chef/provider"
require "chef/util/path_helper"
-require "win32/taskscheduler" if Chef::Platform.windows?
+require "win32/taskscheduler" if ChefHelpers.windows?
class Chef
class Provider
@@ -30,7 +30,7 @@ class Chef
include Chef::Mixin::ShellOut
include Chef::Mixin::PowershellOut
- if Chef::Platform.windows?
+ if ChefHelpers.windows?
include Win32
provides :windows_task