summaryrefslogtreecommitdiff
path: root/lib/chef/provider
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-05-06 17:33:50 -0700
committerJohn Keiser <john@johnkeiser.com>2015-06-02 09:53:40 -0700
commitfa0b9a5a92c477ef5ea84bf90a266943bb1a04c9 (patch)
treee2f7d6a8a7cf70894b9caead82bc306735c2e99e /lib/chef/provider
parent8a968eeb58139b00e8bfc35b52cb9150515525a8 (diff)
downloadchef-fa0b9a5a92c477ef5ea84bf90a266943bb1a04c9.tar.gz
Move provider_mapping values out into the actual resource classes
Diffstat (limited to 'lib/chef/provider')
-rw-r--r--lib/chef/provider/group/aix.rb1
-rw-r--r--lib/chef/provider/group/gpasswd.rb1
-rw-r--r--lib/chef/provider/group/pw.rb1
-rw-r--r--lib/chef/provider/group/suse.rb6
-rw-r--r--lib/chef/provider/group/usermod.rb6
-rw-r--r--lib/chef/provider/ifconfig.rb2
-rw-r--r--lib/chef/provider/ifconfig/aix.rb1
-rw-r--r--lib/chef/provider/ifconfig/debian.rb1
-rw-r--r--lib/chef/provider/ifconfig/redhat.rb1
-rw-r--r--lib/chef/provider/mount.rb3
-rw-r--r--lib/chef/provider/mount/aix.rb1
-rw-r--r--lib/chef/provider/mount/solaris.rb2
-rw-r--r--lib/chef/provider/package.rb22
-rw-r--r--lib/chef/provider/service.rb96
-rw-r--r--lib/chef/provider/user.rb2
-rw-r--r--lib/chef/provider/user/aix.rb5
-rw-r--r--lib/chef/provider/user/pw.rb1
-rw-r--r--lib/chef/provider/user/solaris.rb2
-rw-r--r--lib/chef/provider/user/useradd.rb1
19 files changed, 100 insertions, 55 deletions
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"]]