diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/platform/provider_mapping.rb | 267 | ||||
-rw-r--r-- | lib/chef/provider.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/group/aix.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/group/gpasswd.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/group/pw.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/group/suse.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/group/usermod.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/ifconfig.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/ifconfig/aix.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/ifconfig/debian.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/ifconfig/redhat.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/mount.rb | 3 | ||||
-rw-r--r-- | lib/chef/provider/mount/aix.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/mount/solaris.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/package.rb | 22 | ||||
-rw-r--r-- | lib/chef/provider/service.rb | 96 | ||||
-rw-r--r-- | lib/chef/provider/user.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/user/aix.rb | 5 | ||||
-rw-r--r-- | lib/chef/provider/user/pw.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/user/solaris.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/user/useradd.rb | 1 |
21 files changed, 101 insertions, 322 deletions
diff --git a/lib/chef/platform/provider_mapping.rb b/lib/chef/platform/provider_mapping.rb index 00458b6485..7e9c4028e0 100644 --- a/lib/chef/platform/provider_mapping.rb +++ b/lib/chef/platform/provider_mapping.rb @@ -20,13 +20,8 @@ require 'chef/log' require 'chef/exceptions' require 'chef/mixin/params_validate' require 'chef/version_constraint/platform' - -# This file depends on nearly every provider in chef, but requiring them -# directly causes circular requires resulting in uninitialized constant errors. -# Therefore, we do the includes inline rather than up top. require 'chef/provider' - class Chef class Platform @@ -34,267 +29,7 @@ class Chef attr_writer :platforms def platforms - @platforms ||= begin - require 'chef/providers' - - { - :freebsd => { - :default => { - :group => Chef::Provider::Group::Pw, - :user => Chef::Provider::User::Pw, - } - }, - :ubuntu => { - :default => { - :package => Chef::Provider::Package::Apt, - :service => Chef::Provider::Service::Debian, - }, - ">= 11.10" => { - :ifconfig => Chef::Provider::Ifconfig::Debian - } - # Chef::Provider::Service::Upstart is a candidate to be used in - # ubuntu versions >= 13.10 but it currently requires all the - # services to have an entry under /etc/init. We need to update it - # to use the service ctl apis in order to migrate to using it on - # ubuntu >= 13.10. - }, - :gcel => { - :default => { - :package => Chef::Provider::Package::Apt, - :service => Chef::Provider::Service::Debian, - } - }, - :linaro => { - :default => { - :package => Chef::Provider::Package::Apt, - :service => Chef::Provider::Service::Debian, - } - }, - :raspbian => { - :default => { - :package => Chef::Provider::Package::Apt, - :service => Chef::Provider::Service::Debian, - } - }, - :linuxmint => { - :default => { - :package => Chef::Provider::Package::Apt, - :service => Chef::Provider::Service::Upstart, - } - }, - :debian => { - :default => { - :package => Chef::Provider::Package::Apt, - :service => Chef::Provider::Service::Debian, - }, - ">= 6.0" => { - :service => Chef::Provider::Service::Insserv - }, - ">= 7.0" => { - :ifconfig => Chef::Provider::Ifconfig::Debian - } - }, - :xenserver => { - :default => { - :service => Chef::Provider::Service::Redhat, - :package => Chef::Provider::Package::Yum, - } - }, - :xcp => { - :default => { - :service => Chef::Provider::Service::Redhat, - :package => Chef::Provider::Package::Yum, - } - }, - :centos => { - :default => { - :service => Chef::Provider::Service::Systemd, - :package => Chef::Provider::Package::Yum, - :ifconfig => Chef::Provider::Ifconfig::Redhat - }, - "< 7" => { - :service => Chef::Provider::Service::Redhat - } - }, - :amazon => { - :default => { - :service => Chef::Provider::Service::Redhat, - :package => Chef::Provider::Package::Yum, - } - }, - :scientific => { - :default => { - :service => Chef::Provider::Service::Systemd, - :package => Chef::Provider::Package::Yum, - }, - "< 7" => { - :service => Chef::Provider::Service::Redhat - } - }, - :fedora => { - :default => { - :service => Chef::Provider::Service::Systemd, - :package => Chef::Provider::Package::Yum, - :ifconfig => Chef::Provider::Ifconfig::Redhat - }, - "< 15" => { - :service => Chef::Provider::Service::Redhat - } - }, - :opensuse => { - :default => { - :service => Chef::Provider::Service::Redhat, - :package => Chef::Provider::Package::Zypper, - :group => Chef::Provider::Group::Suse - }, - # Only OpenSuSE 12.3+ should use the Usermod group provider: - ">= 12.3" => { - :group => Chef::Provider::Group::Usermod - } - }, - :suse => { - :default => { - :service => Chef::Provider::Service::Systemd, - :package => Chef::Provider::Package::Zypper, - :group => Chef::Provider::Group::Gpasswd - }, - "< 12.0" => { - :group => Chef::Provider::Group::Suse, - :service => Chef::Provider::Service::Redhat - } - }, - :oracle => { - :default => { - :service => Chef::Provider::Service::Systemd, - :package => Chef::Provider::Package::Yum, - }, - "< 7" => { - :service => Chef::Provider::Service::Redhat - } - }, - :redhat => { - :default => { - :service => Chef::Provider::Service::Systemd, - :package => Chef::Provider::Package::Yum, - :ifconfig => Chef::Provider::Ifconfig::Redhat - }, - "< 7" => { - :service => Chef::Provider::Service::Redhat - } - }, - :ibm_powerkvm => { - :default => { - :service => Chef::Provider::Service::Redhat, - :package => Chef::Provider::Package::Yum, - :ifconfig => Chef::Provider::Ifconfig::Redhat - } - }, - :cloudlinux => { - :default => { - :service => Chef::Provider::Service::Redhat, - :package => Chef::Provider::Package::Yum, - :ifconfig => Chef::Provider::Ifconfig::Redhat - } - }, - :parallels => { - :default => { - :service => Chef::Provider::Service::Redhat, - :package => Chef::Provider::Package::Yum, - :ifconfig => Chef::Provider::Ifconfig::Redhat - } - }, - :gentoo => { - :default => { - :package => Chef::Provider::Package::Portage, - :service => Chef::Provider::Service::Gentoo, - } - }, - :arch => { - :default => { - :package => Chef::Provider::Package::Pacman, - :service => Chef::Provider::Service::Systemd, - } - }, - :solaris => {}, - :openindiana => { - :default => { - :mount => Chef::Provider::Mount::Solaris, - :package => Chef::Provider::Package::Ips, - :group => Chef::Provider::Group::Usermod - } - }, - :opensolaris => { - :default => { - :mount => Chef::Provider::Mount::Solaris, - :package => Chef::Provider::Package::Ips, - :group => Chef::Provider::Group::Usermod - } - }, - :nexentacore => { - :default => { - :mount => Chef::Provider::Mount::Solaris, - :package => Chef::Provider::Package::Solaris, - :group => Chef::Provider::Group::Usermod - } - }, - :omnios => { - :default => { - :mount => Chef::Provider::Mount::Solaris, - :package => Chef::Provider::Package::Ips, - :group => Chef::Provider::Group::Usermod, - :user => Chef::Provider::User::Solaris, - } - }, - :solaris2 => { - :default => { - :mount => Chef::Provider::Mount::Solaris, - :package => Chef::Provider::Package::Ips, - :group => Chef::Provider::Group::Usermod, - :user => Chef::Provider::User::Solaris, - }, - "< 5.11" => { - :mount => Chef::Provider::Mount::Solaris, - :package => Chef::Provider::Package::Solaris, - :group => Chef::Provider::Group::Usermod, - :user => Chef::Provider::User::Solaris, - } - }, - :smartos => { - :default => { - :mount => Chef::Provider::Mount::Solaris, - :package => Chef::Provider::Package::SmartOS, - :group => Chef::Provider::Group::Usermod - } - }, - :hpux => { - :default => { - :group => Chef::Provider::Group::Usermod - } - }, - :aix => { - :default => { - :group => Chef::Provider::Group::Aix, - :mount => Chef::Provider::Mount::Aix, - :ifconfig => Chef::Provider::Ifconfig::Aix, - :package => Chef::Provider::Package::Aix, - :user => Chef::Provider::User::Aix, - :service => Chef::Provider::Service::Aix - } - }, - :exherbo => { - :default => { - :package => Chef::Provider::Package::Paludis, - :service => Chef::Provider::Service::Systemd, - } - }, - :default => { - :mount => Chef::Provider::Mount::Mount, - :user => Chef::Provider::User::Useradd, - :group => Chef::Provider::Group::Gpasswd, - :ifconfig => Chef::Provider::Ifconfig, - } - } - end + @platforms ||= { default: {} } end include Chef::Mixin::ParamsValidate diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb index 8027e39a3f..e50e374804 100644 --- a/lib/chef/provider.rb +++ b/lib/chef/provider.rb @@ -244,5 +244,4 @@ end require 'chef/chef_class' require 'chef/mixin/why_run' require 'chef/resource_collection' -require 'chef/platform/provider_priority_map' require 'chef/runner' diff --git a/lib/chef/provider/group/aix.rb b/lib/chef/provider/group/aix.rb index 6ac9d03357..7d6735a66d 100644 --- a/lib/chef/provider/group/aix.rb +++ b/lib/chef/provider/group/aix.rb @@ -23,6 +23,7 @@ class Chef class Provider class Group class Aix < Chef::Provider::Group::Groupadd + provides :group, platform: %w(aix) def required_binaries [ "/usr/bin/mkgroup", diff --git a/lib/chef/provider/group/gpasswd.rb b/lib/chef/provider/group/gpasswd.rb index 521affac11..33c594d9a0 100644 --- a/lib/chef/provider/group/gpasswd.rb +++ b/lib/chef/provider/group/gpasswd.rb @@ -22,6 +22,7 @@ class Chef class Provider class Group class Gpasswd < Chef::Provider::Group::Groupadd + provides :group, platform: %w(suse default) def load_current_resource super diff --git a/lib/chef/provider/group/pw.rb b/lib/chef/provider/group/pw.rb index 7a66ab4d69..2758d5dea5 100644 --- a/lib/chef/provider/group/pw.rb +++ b/lib/chef/provider/group/pw.rb @@ -20,6 +20,7 @@ class Chef class Provider class Group class Pw < Chef::Provider::Group + provides :group, platform: %w(freebsd) def load_current_resource super diff --git a/lib/chef/provider/group/suse.rb b/lib/chef/provider/group/suse.rb index 7ac2831d02..3831b555e6 100644 --- a/lib/chef/provider/group/suse.rb +++ b/lib/chef/provider/group/suse.rb @@ -22,6 +22,12 @@ class Chef class Provider class Group class Suse < Chef::Provider::Group::Groupadd + provides :group, platform: %w(opensuse) + provides :group, platform: %w(suse) do |node| + if node[:platform_version] + Chef::VersionConstraint::Platform.new('< 12.0').include?(node[:platform_version]) + end + end def load_current_resource super diff --git a/lib/chef/provider/group/usermod.rb b/lib/chef/provider/group/usermod.rb index e50e13c443..465592af28 100644 --- a/lib/chef/provider/group/usermod.rb +++ b/lib/chef/provider/group/usermod.rb @@ -24,6 +24,12 @@ class Chef class Usermod < Chef::Provider::Group::Groupadd provides :group, os: "openbsd" + provides :group, platform: %w(opensuse) do |node| + if node[:platform_version] + Chef::VersionConstraint::Platform.new('>= 12.3').include?(node[:platform_version]) + end + end + provides :group, platform: %w(openindiana opensolaris nexentacore omnios solaris2 smartos hpux) def load_current_resource super diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 06080c90c3..468e1ec639 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -39,6 +39,8 @@ require 'erb' class Chef class Provider class Ifconfig < Chef::Provider + provides :ifconfig + include Chef::Mixin::ShellOut include Chef::Mixin::Command diff --git a/lib/chef/provider/ifconfig/aix.rb b/lib/chef/provider/ifconfig/aix.rb index 8fead44bc6..9b14cb8a81 100644 --- a/lib/chef/provider/ifconfig/aix.rb +++ b/lib/chef/provider/ifconfig/aix.rb @@ -22,6 +22,7 @@ class Chef class Provider class Ifconfig class Aix < Chef::Provider::Ifconfig + Aix.provides :ifconfig, platform: %w(aix) def load_current_resource @current_resource = Chef::Resource::Ifconfig.new(@new_resource.name) diff --git a/lib/chef/provider/ifconfig/debian.rb b/lib/chef/provider/ifconfig/debian.rb index 7589971143..85765a6fea 100644 --- a/lib/chef/provider/ifconfig/debian.rb +++ b/lib/chef/provider/ifconfig/debian.rb @@ -23,6 +23,7 @@ class Chef class Provider class Ifconfig class Debian < Chef::Provider::Ifconfig + provides :ifconfig, platform: %w(ubuntu >= 11.10 debian >= 7.0) INTERFACES_FILE = "/etc/network/interfaces" INTERFACES_DOT_D_DIR = "/etc/network/interfaces.d" diff --git a/lib/chef/provider/ifconfig/redhat.rb b/lib/chef/provider/ifconfig/redhat.rb index ef35b0e012..692c2a32bf 100644 --- a/lib/chef/provider/ifconfig/redhat.rb +++ b/lib/chef/provider/ifconfig/redhat.rb @@ -22,6 +22,7 @@ class Chef class Provider class Ifconfig class Redhat < Chef::Provider::Ifconfig + provides :ifconfig, platform: %w(centos fedora redhat ibm_powerkvm cloudlinux parallels) def initialize(new_resource, run_context) super(new_resource, run_context) diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb index 1631d87033..47d4cb0851 100644 --- a/lib/chef/provider/mount.rb +++ b/lib/chef/provider/mount.rb @@ -24,7 +24,8 @@ require 'chef/provider' class Chef class Provider class Mount < Chef::Provider - + Mount.provides :mount + include Chef::Mixin::ShellOut attr_accessor :unmount_retries diff --git a/lib/chef/provider/mount/aix.rb b/lib/chef/provider/mount/aix.rb index 0d7e11a1b8..4ad7b24c15 100644 --- a/lib/chef/provider/mount/aix.rb +++ b/lib/chef/provider/mount/aix.rb @@ -22,6 +22,7 @@ class Chef class Provider class Mount class Aix < Chef::Provider::Mount::Mount + provides :mount, platform: %w(aix) # Override for aix specific handling def initialize(new_resource, run_context) diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb index d8cec24138..ae671ab88a 100644 --- a/lib/chef/provider/mount/solaris.rb +++ b/lib/chef/provider/mount/solaris.rb @@ -27,6 +27,8 @@ class Chef class Mount # Mount Solaris File systems class Solaris < Chef::Provider::Mount + provides :mount, platform: %w(openindiana opensolaris nexentacore omnios solaris2 solaris2 < 5.11 smartos) + extend Forwardable VFSTAB = '/etc/vfstab'.freeze diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb index b903ef5f42..545db9eb8a 100644 --- a/lib/chef/provider/package.rb +++ b/lib/chef/provider/package.rb @@ -25,6 +25,8 @@ require 'chef/platform' class Chef class Provider class Package < Chef::Provider + provides :package + include Chef::Mixin::Command include Chef::Mixin::ShellOut @@ -495,8 +497,28 @@ class Chef require 'chef/chef_class' require 'chef/provider/package/homebrew' require 'chef/provider/package/macports' + require 'chef/provider/package/apt' + require 'chef/provider/package/yum' + require 'chef/provider/package/zypper' + require 'chef/provider/package/portage' + require 'chef/provider/package/pacman' + require 'chef/provider/package/ips' + require 'chef/provider/package/solaris' + require 'chef/provider/package/smartos' + require 'chef/provider/package/aix' + require 'chef/provider/package/paludis' Chef.set_provider_priority_array :package, [ Homebrew, Macports ], os: "darwin" + Chef.set_provider_priority_array :package, Apt, platform: %w(ubuntu gcel linaro raspbian linuxmint debian) + Chef.set_provider_priority_array :package, Yum, platform: %w(xenserver xcp centos amazon scientific fedora oracle redhat ibm_powerkvm cloudlinux parallels) + Chef.set_provider_priority_array :package, Zypper, platform: %w(opensuse suse) + Chef.set_provider_priority_array :package, Portage, platform: %w(gentoo) + Chef.set_provider_priority_array :package, Pacman, platform: %w(arch) + Chef.set_provider_priority_array :package, Ips, platform: %w(openindiana opensolaris omnios solaris2) + Chef.set_provider_priority_array :package, Solaris, platform: %w(nexentacore solaris2 < 5.11) + Chef.set_provider_priority_array :package, SmartOS, platform: %w(smartos) + Chef.set_provider_priority_array :package, Aix, platform: %w(aix) + Chef.set_provider_priority_array :package, Paludis, platform: %w(exherbo) end end end diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb index 8af04ec39f..1bdc22627e 100644 --- a/lib/chef/provider/service.rb +++ b/lib/chef/provider/service.rb @@ -23,6 +23,8 @@ class Chef class Provider class Service < Chef::Provider + provides :service + include Chef::Mixin::Command def initialize(new_resource, run_context) @@ -169,57 +171,49 @@ class Chef !!@new_resource.send(method_name) end - # - # Platform-specific versions - # - - # - # Linux - # - - require 'chef/chef_class' - require 'chef/provider/service/systemd' - require 'chef/provider/service/insserv' - require 'chef/provider/service/redhat' - require 'chef/provider/service/arch' - require 'chef/provider/service/gentoo' - require 'chef/provider/service/upstart' - require 'chef/provider/service/debian' - require 'chef/provider/service/invokercd' - require 'chef/provider/service/freebsd' - require 'chef/provider/service/openbsd' - require 'chef/provider/service/solaris' - require 'chef/provider/service/macosx' - - # default block for linux O/Sen must come before platform_family exceptions - # so that they take precedence - Chef.set_provider_priority_array :service, [ Systemd, Insserv, Redhat ], - os: "linux" - - Chef.set_provider_priority_array :service, [ Systemd, Arch ], - platform_family: "arch" - Chef.set_provider_priority_array :service, [ Systemd, Gentoo ], - platform_family: "gentoo" - # we can determine what systemd supports accurately - # on debian-ish system if an upstart script exists that must win over sysv types - 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) - - # BSDen - Chef.set_provider_priority_array :service, Freebsd, - os: %w(freebsd netbsd) - Chef.set_provider_priority_array :service, Openbsd, - os: "openbsd" - - # Solaris-en - Chef.set_provider_priority_array :service, Solaris, - os: "solaris2" - - # Mac - Chef.set_provider_priority_array :service, Macosx, - os: "darwin" + module ServicePriorityInit + + # + # Platform-specific versions + # + + # + # Linux + # + + require 'chef/chef_class' + require 'chef/provider/service/systemd' + require 'chef/provider/service/insserv' + require 'chef/provider/service/redhat' + require 'chef/provider/service/arch' + require 'chef/provider/service/gentoo' + require 'chef/provider/service/upstart' + require 'chef/provider/service/debian' + require 'chef/provider/service/invokercd' + require 'chef/provider/service/freebsd' + require 'chef/provider/service/openbsd' + require 'chef/provider/service/solaris' + require 'chef/provider/service/macosx' + + def self.os(os, *providers) + Chef.set_provider_priority_array(:service, providers, os: os) + end + def self.platform_family(platform_family, *providers) + Chef.set_provider_priority_array(:service, providers, platform_family: platform_family) + end + + os %w(freebsd netbsd), Freebsd + os %w(openbsd), Openbsd + os %w(solaris2), Solaris + os %w(darwin), Macosx + os %w(linux), Systemd, Insserv, Redhat + + platform_family %w(arch), Systemd, Arch + platform_family %w(gentoo), Systemd, Gentoo + platform_family %w(debian), Systemd, Upstart, Insserv, Debian, Invokercd + platform_family %w(rhel fedora suse), Systemd, Insserv, Redhat + + end end end end diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb index f6ac72448e..ad92a72a0a 100644 --- a/lib/chef/provider/user.rb +++ b/lib/chef/provider/user.rb @@ -23,6 +23,7 @@ require 'etc' class Chef class Provider class User < Chef::Provider + provides :user include Chef::Mixin::Command @@ -208,7 +209,6 @@ class Chef def unlock_user raise NotImplementedError end - end end end diff --git a/lib/chef/provider/user/aix.rb b/lib/chef/provider/user/aix.rb index af08ab4364..a575a41e54 100644 --- a/lib/chef/provider/user/aix.rb +++ b/lib/chef/provider/user/aix.rb @@ -18,9 +18,10 @@ class Chef class Provider class User class Aix < Chef::Provider::User::Useradd + provides :user, platform: %w(aix) UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]] - + def create_user super add_password @@ -88,7 +89,7 @@ class Chef end end end - + end end end diff --git a/lib/chef/provider/user/pw.rb b/lib/chef/provider/user/pw.rb index fe71e93561..810ffb9a8d 100644 --- a/lib/chef/provider/user/pw.rb +++ b/lib/chef/provider/user/pw.rb @@ -22,6 +22,7 @@ class Chef class Provider class User class Pw < Chef::Provider::User + provides :user, platform: %w(freebsd) def load_current_resource super diff --git a/lib/chef/provider/user/solaris.rb b/lib/chef/provider/user/solaris.rb index d480acaced..b242095f0c 100644 --- a/lib/chef/provider/user/solaris.rb +++ b/lib/chef/provider/user/solaris.rb @@ -22,6 +22,8 @@ class Chef class Provider class User class Solaris < Chef::Provider::User::Useradd + provides :user, platform: %w(omnios solaris2) + UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:shell, "-s"], [:uid, "-u"]] attr_writer :password_file diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb index cc770c0be2..a1b5b3459c 100644 --- a/lib/chef/provider/user/useradd.rb +++ b/lib/chef/provider/user/useradd.rb @@ -23,6 +23,7 @@ class Chef class Provider class User class Useradd < Chef::Provider::User + provides :user UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:password, "-p"], [:shell, "-s"], [:uid, "-u"]] |