diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-07-29 00:30:26 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-07-29 00:30:26 -0700 |
commit | 9e85bbdb9419e5b9946ab6d0d37817612e43cc4a (patch) | |
tree | b8d2049f768471e8cba29ab08c64c08a623bd5e0 | |
parent | 4edfb5be4391f1b6ad54e472b1721af00fbada5e (diff) | |
download | chef-9e85bbdb9419e5b9946ab6d0d37817612e43cc4a.tar.gz |
add shell_out to base provider code
34 files changed, 14 insertions, 64 deletions
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb index 90b6ead716..db7629dbcb 100644 --- a/lib/chef/provider.rb +++ b/lib/chef/provider.rb @@ -22,11 +22,13 @@ require 'chef/mixin/convert_to_class_name' require 'chef/dsl/recipe' require 'chef/mixin/enforce_ownership_and_permissions' require 'chef/mixin/why_run' +require 'chef/mixin/shell_out' class Chef class Provider include Chef::DSL::Recipe include Chef::Mixin::WhyRun + include Chef::Mixin::ShellOut attr_accessor :new_resource attr_accessor :current_resource diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb index 2907688e88..b494e6678e 100644 --- a/lib/chef/provider/execute.rb +++ b/lib/chef/provider/execute.rb @@ -16,7 +16,6 @@ # limitations under the License. # -require 'chef/mixin/shell_out' require 'chef/log' require 'chef/provider' @@ -24,7 +23,6 @@ class Chef class Provider class Execute < Chef::Provider - include Chef::Mixin::ShellOut def load_current_resource true diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb index 2dffcc6ddc..e1db4d00dc 100644 --- a/lib/chef/provider/file.rb +++ b/lib/chef/provider/file.rb @@ -25,7 +25,6 @@ require 'etc' require 'fileutils' require 'chef/scan_access_control' require 'chef/mixin/checksum' -require 'chef/mixin/shell_out' require 'chef/mixin/file_class' require 'chef/util/backup' require 'chef/util/diff' @@ -48,7 +47,6 @@ class Chef class File < Chef::Provider include Chef::Mixin::EnforceOwnershipAndPermissions include Chef::Mixin::Checksum - include Chef::Mixin::ShellOut include Chef::Util::Selinux include Chef::Mixin::FileClass diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb index 3999edc16a..8499fe49b8 100644 --- a/lib/chef/provider/git.rb +++ b/lib/chef/provider/git.rb @@ -20,14 +20,12 @@ require 'chef/exceptions' require 'chef/log' require 'chef/provider' -require 'chef/mixin/shell_out' require 'fileutils' class Chef class Provider class Git < Chef::Provider - include Chef::Mixin::ShellOut def whyrun_supported? true diff --git a/lib/chef/provider/group/gpasswd.rb b/lib/chef/provider/group/gpasswd.rb index a65a7ffd53..2ac98f85ac 100644 --- a/lib/chef/provider/group/gpasswd.rb +++ b/lib/chef/provider/group/gpasswd.rb @@ -17,14 +17,12 @@ # require 'chef/provider/group/groupadd' -require 'chef/mixin/shell_out' class Chef class Provider class Group class Gpasswd < Chef::Provider::Group::Groupadd - include Chef::Mixin::ShellOut def load_current_resource super diff --git a/lib/chef/provider/group/groupmod.rb b/lib/chef/provider/group/groupmod.rb index c8b6458db0..ae89f3af93 100644 --- a/lib/chef/provider/group/groupmod.rb +++ b/lib/chef/provider/group/groupmod.rb @@ -16,14 +16,12 @@ # limitations under the License. # -require 'chef/mixin/shell_out' class Chef class Provider class Group class Groupmod < Chef::Provider::Group - include Chef::Mixin::ShellOut def load_current_resource super diff --git a/lib/chef/provider/group/suse.rb b/lib/chef/provider/group/suse.rb index 14380f1705..451af5fc45 100644 --- a/lib/chef/provider/group/suse.rb +++ b/lib/chef/provider/group/suse.rb @@ -17,14 +17,12 @@ # require 'chef/provider/group/groupadd' -require 'chef/mixin/shell_out' class Chef class Provider class Group class Suse < Chef::Provider::Group::Groupadd - include Chef::Mixin::ShellOut def load_current_resource super diff --git a/lib/chef/provider/group/usermod.rb b/lib/chef/provider/group/usermod.rb index e6f3fc9e0f..fac6afb9f9 100644 --- a/lib/chef/provider/group/usermod.rb +++ b/lib/chef/provider/group/usermod.rb @@ -17,14 +17,12 @@ # require 'chef/provider/group/groupadd' -require 'chef/mixin/shell_out' class Chef class Provider class Group class Usermod < Chef::Provider::Group::Groupadd - include Chef::Mixin::ShellOut def load_current_resource super diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb index c41fbcad95..d6602c2e03 100644 --- a/lib/chef/provider/link.rb +++ b/lib/chef/provider/link.rb @@ -18,7 +18,6 @@ require 'chef/config' require 'chef/log' -require 'chef/mixin/shell_out' require 'chef/mixin/file_class' require 'chef/resource/link' require 'chef/provider' @@ -29,7 +28,6 @@ class Chef class Link < Chef::Provider include Chef::Mixin::EnforceOwnershipAndPermissions - include Chef::Mixin::ShellOut include Chef::Mixin::FileClass def negative_complement(big) diff --git a/lib/chef/provider/mdadm.rb b/lib/chef/provider/mdadm.rb index 51c9b8d3c6..4a34a5c2ce 100644 --- a/lib/chef/provider/mdadm.rb +++ b/lib/chef/provider/mdadm.rb @@ -17,14 +17,12 @@ # require 'chef/log' -require 'chef/mixin/shell_out' require 'chef/provider' class Chef class Provider class Mdadm < Chef::Provider - include Chef::Mixin::ShellOut def popen4 raise Exception, "deprecated" diff --git a/lib/chef/provider/mount/mount.rb b/lib/chef/provider/mount/mount.rb index 22d61a9236..bb1b796290 100644 --- a/lib/chef/provider/mount/mount.rb +++ b/lib/chef/provider/mount/mount.rb @@ -18,13 +18,11 @@ require 'chef/provider/mount' require 'chef/log' -require 'chef/mixin/shell_out' class Chef class Provider class Mount class Mount < Chef::Provider::Mount - include Chef::Mixin::ShellOut def initialize(new_resource, run_context) super diff --git a/lib/chef/provider/mount/solaris.rb b/lib/chef/provider/mount/solaris.rb index 85158eb564..462fa32b71 100644 --- a/lib/chef/provider/mount/solaris.rb +++ b/lib/chef/provider/mount/solaris.rb @@ -20,14 +20,12 @@ require 'chef/provider/mount' require 'chef/log' -require 'chef/mixin/shell_out' require 'forwardable' class Chef class Provider class Mount class Solaris < Chef::Provider::Mount - include Chef::Mixin::ShellOut extend Forwardable VFSTAB = "/etc/vfstab".freeze diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb index 76d90a5a97..82264c1acf 100644 --- a/lib/chef/provider/package/apt.rb +++ b/lib/chef/provider/package/apt.rb @@ -19,7 +19,6 @@ require 'chef/provider/package' require 'chef/mixin/command' require 'chef/resource/package' -require 'chef/mixin/shell_out' class Chef @@ -27,7 +26,6 @@ class Chef class Package class Apt < Chef::Provider::Package - include Chef::Mixin::ShellOut attr_accessor :is_virtual_package def load_current_resource diff --git a/lib/chef/provider/package/easy_install.rb b/lib/chef/provider/package/easy_install.rb index 6c9dacc55d..6cbe3b466a 100644 --- a/lib/chef/provider/package/easy_install.rb +++ b/lib/chef/provider/package/easy_install.rb @@ -18,16 +18,13 @@ require 'chef/provider/package' require 'chef/mixin/command' -require 'chef/mixin/shell_out' require 'chef/resource/package' -require 'chef/mixin/shell_out' class Chef class Provider class Package class EasyInstall < Chef::Provider::Package - include Chef::Mixin::ShellOut def install_check(name) check = false diff --git a/lib/chef/provider/package/freebsd/base.rb b/lib/chef/provider/package/freebsd/base.rb index 24f79484f0..c993738488 100644 --- a/lib/chef/provider/package/freebsd/base.rb +++ b/lib/chef/provider/package/freebsd/base.rb @@ -21,7 +21,6 @@ require 'chef/resource/package' require 'chef/provider/package' -require 'chef/mixin/shell_out' require 'chef/mixin/get_source_from_package' class Chef @@ -65,7 +64,6 @@ class Chef class Base < Chef::Provider::Package - include Chef::Mixin::ShellOut include Chef::Mixin::GetSourceFromPackage def initialize(*args) diff --git a/lib/chef/provider/package/ips.rb b/lib/chef/provider/package/ips.rb index 2c6d98d81a..1f21fbc0fa 100644 --- a/lib/chef/provider/package/ips.rb +++ b/lib/chef/provider/package/ips.rb @@ -21,14 +21,12 @@ require 'open3' require 'chef/provider/package' require 'chef/mixin/command' require 'chef/resource/package' -require 'chef/mixin/shell_out' class Chef class Provider class Package class Ips < Chef::Provider::Package - include Chef::Mixin::ShellOut attr_accessor :virtual def define_resource_requirements diff --git a/lib/chef/provider/package/paludis.rb b/lib/chef/provider/package/paludis.rb index e304cd3b8e..f2a574d6fc 100644 --- a/lib/chef/provider/package/paludis.rb +++ b/lib/chef/provider/package/paludis.rb @@ -18,14 +18,12 @@ require 'chef/provider/package' require 'chef/resource/package' -require 'chef/mixin/shell_out' class Chef class Provider class Package class Paludis < Chef::Provider::Package - include Chef::Mixin::ShellOut def load_current_resource @current_resource = Chef::Resource::Package.new(@new_resource.package_name) diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index b423c199a0..0e404ca58b 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -273,7 +273,6 @@ class Chef @platform_cache ||= {} end - include Chef::Mixin::ShellOut attr_reader :gem_binary_location @@ -352,7 +351,6 @@ class Chef end - include Chef::Mixin::ShellOut attr_reader :gem_env attr_reader :cleanup_gem_env diff --git a/lib/chef/provider/package/smartos.rb b/lib/chef/provider/package/smartos.rb index 28d56ddc2c..576899640a 100644 --- a/lib/chef/provider/package/smartos.rb +++ b/lib/chef/provider/package/smartos.rb @@ -20,7 +20,6 @@ # require 'chef/provider/package' -require 'chef/mixin/shell_out' require 'chef/resource/package' require 'chef/mixin/get_source_from_package' @@ -28,7 +27,6 @@ class Chef class Provider class Package class SmartOS < Chef::Provider::Package - include Chef::Mixin::ShellOut attr_accessor :is_virtual_package diff --git a/lib/chef/provider/package/windows/msi.rb b/lib/chef/provider/package/windows/msi.rb index a342600678..cc07909d8e 100644 --- a/lib/chef/provider/package/windows/msi.rb +++ b/lib/chef/provider/package/windows/msi.rb @@ -18,7 +18,6 @@ # TODO: Allow @new_resource.source to be a Product Code as a GUID for uninstall / network install -require 'chef/mixin/shell_out' require 'chef/win32/api/installer' if RUBY_PLATFORM =~ /mswin|mingw32|windows/ class Chef @@ -27,7 +26,6 @@ class Chef class Windows class MSI include Chef::ReservedNames::Win32::API::Installer if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - include Chef::Mixin::ShellOut def initialize(resource) @new_resource = resource diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index c241c7fd6d..64ccca30a5 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -19,7 +19,6 @@ require 'chef/config' require 'chef/provider/package' require 'chef/mixin/command' -require 'chef/mixin/shell_out' require 'chef/resource/package' require 'singleton' require 'chef/mixin/get_source_from_package' @@ -647,7 +646,6 @@ class Chef # Cache for our installed and available packages, pulled in from yum-dump.py class YumCache include Chef::Mixin::Command - include Chef::Mixin::ShellOut include Singleton def initialize @@ -949,7 +947,6 @@ class Chef end # YumCache include Chef::Mixin::GetSourceFromPackage - include Chef::Mixin::ShellOut def initialize(new_resource, run_context) super diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb index b288d5d954..5616cc1512 100644 --- a/lib/chef/provider/package/zypper.rb +++ b/lib/chef/provider/package/zypper.rb @@ -22,7 +22,6 @@ require 'chef/provider/package' require 'chef/mixin/command' require 'chef/resource/package' -require 'chef/mixin/shell_out' require 'singleton' class Chef @@ -30,7 +29,6 @@ class Chef class Package class Zypper < Chef::Provider::Package - include Chef::Mixin::ShellOut def load_current_resource @current_resource = Chef::Resource::Package.new(@new_resource.name) diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb index 3b5be93ba1..01ee57895e 100644 --- a/lib/chef/provider/registry_key.rb +++ b/lib/chef/provider/registry_key.rb @@ -25,7 +25,6 @@ require 'chef/provider' require 'etc' require 'fileutils' require 'chef/scan_access_control' -require 'chef/mixin/shell_out' require 'chef/win32/registry' class Chef @@ -33,7 +32,6 @@ class Chef class Provider class RegistryKey < Chef::Provider include Chef::Mixin::Checksum - include Chef::Mixin::ShellOut def whyrun_supported? true diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb index 7da29851c2..7f382fe287 100644 --- a/lib/chef/provider/service/freebsd.rb +++ b/lib/chef/provider/service/freebsd.rb @@ -16,7 +16,6 @@ # limitations under the License. # -require 'chef/mixin/shell_out' require 'chef/resource/service' require 'chef/provider/service/init' require 'chef/mixin/command' @@ -26,7 +25,6 @@ class Chef class Service class Freebsd < Chef::Provider::Service::Init - include Chef::Mixin::ShellOut def load_current_resource @current_resource = Chef::Resource::Service.new(@new_resource.name) diff --git a/lib/chef/provider/service/init.rb b/lib/chef/provider/service/init.rb index 64f4074d8b..81c9442444 100644 --- a/lib/chef/provider/service/init.rb +++ b/lib/chef/provider/service/init.rb @@ -16,7 +16,6 @@ # limitations under the License. # -require 'chef/mixin/shell_out' require 'chef/provider/service/simple' require 'chef/mixin/command' @@ -25,7 +24,6 @@ class Chef class Service class Init < Chef::Provider::Service::Simple - include Chef::Mixin::ShellOut def initialize(new_resource, run_context) super diff --git a/lib/chef/provider/service/macosx.rb b/lib/chef/provider/service/macosx.rb index 2642a7e204..36930ee4ac 100644 --- a/lib/chef/provider/service/macosx.rb +++ b/lib/chef/provider/service/macosx.rb @@ -24,7 +24,6 @@ class Chef class Provider class Service class Macosx < Chef::Provider::Service::Simple - include Chef::Mixin::ShellOut def self.gather_plist_dirs locations = %w{/Library/LaunchAgents diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb index 5275bcac29..7a7b2a1c40 100644 --- a/lib/chef/provider/service/redhat.rb +++ b/lib/chef/provider/service/redhat.rb @@ -17,13 +17,11 @@ # require 'chef/provider/service/init' -require 'chef/mixin/shell_out' class Chef class Provider class Service class Redhat < Chef::Provider::Service::Init - include Chef::Mixin::ShellOut CHKCONFIG_ON = /\d:on/ CHKCONFIG_MISSING = /No such/ diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb index 3b3e539d40..1bd74e32c9 100644 --- a/lib/chef/provider/service/simple.rb +++ b/lib/chef/provider/service/simple.rb @@ -16,7 +16,6 @@ # limitations under the License. # -require 'chef/mixin/shell_out' require 'chef/provider/service' require 'chef/resource/service' require 'chef/mixin/command' @@ -26,7 +25,6 @@ class Chef class Service class Simple < Chef::Provider::Service - include Chef::Mixin::ShellOut def load_current_resource @current_resource = Chef::Resource::Service.new(@new_resource.name) diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb index 69a79e6226..39a52454cf 100644 --- a/lib/chef/provider/service/solaris.rb +++ b/lib/chef/provider/service/solaris.rb @@ -16,7 +16,6 @@ # limitations under the License. # -require 'chef/mixin/shell_out' require 'chef/provider/service' require 'chef/resource/service' require 'chef/mixin/command' @@ -25,7 +24,6 @@ class Chef class Provider class Service class Solaris < Chef::Provider::Service - include Chef::Mixin::ShellOut attr_reader :maintenance def initialize(new_resource, run_context=nil) diff --git a/lib/chef/provider/service/systemd.rb b/lib/chef/provider/service/systemd.rb index ea43e658e4..6231603d03 100644 --- a/lib/chef/provider/service/systemd.rb +++ b/lib/chef/provider/service/systemd.rb @@ -18,7 +18,6 @@ require 'chef/resource/service' require 'chef/provider/service/simple' -require 'chef/mixin/shell_out' class Chef::Provider::Service::Systemd < Chef::Provider::Service::Simple def load_current_resource diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb index 2cfa9d44c1..d14aaf02e9 100644 --- a/lib/chef/provider/service/windows.rb +++ b/lib/chef/provider/service/windows.rb @@ -18,7 +18,6 @@ # limitations under the License. # -require 'chef/mixin/shell_out' require 'chef/provider/service/simple' if RUBY_PLATFORM =~ /mswin|mingw32|windows/ require 'win32/service' @@ -26,7 +25,6 @@ end class Chef::Provider::Service::Windows < Chef::Provider::Service - include Chef::Mixin::ShellOut #Win32::Service.get_start_type AUTO_START = 'auto start' diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index b01931609e..96b5db24ba 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -16,7 +16,6 @@ # limitations under the License. # -require 'chef/mixin/shell_out' require 'chef/provider/user' require 'openssl' @@ -24,7 +23,6 @@ class Chef class Provider class User class Dscl < Chef::Provider::User - include Chef::Mixin::ShellOut NFS_HOME_DIRECTORY = %r{^NFSHomeDirectory: (.*)$} AUTHENTICATION_AUTHORITY = %r{^AuthenticationAuthority: (.*)$} diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb index 201bcbe542..2b219320f1 100644 --- a/lib/chef/provider/user/useradd.rb +++ b/lib/chef/provider/user/useradd.rb @@ -17,7 +17,6 @@ # require 'pathname' -require 'chef/mixin/shell_out' require 'chef/provider/user' class Chef @@ -25,7 +24,6 @@ class Chef class User class Useradd < Chef::Provider::User - include Chef::Mixin::ShellOut UNIVERSAL_OPTIONS = [[:comment, "-c"], [:gid, "-g"], [:password, "-p"], [:shell, "-s"], [:uid, "-u"]] diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb index 363649ec46..9b89fc1888 100644 --- a/spec/unit/provider_spec.rb +++ b/spec/unit/provider_spec.rb @@ -61,6 +61,18 @@ describe Chef::Provider do @provider = Chef::Provider.new(@resource, @run_context) end + it "should mixin shell_out" do + expect(@provider.respond_to?(:shell_out)).to be true + end + + it "should mixin shell_out!" do + expect(@provider.respond_to?(:shell_out!)).to be true + end + + it "should mixin shell_out_with_systems_locale" do + expect(@provider.respond_to?(:shell_out_with_systems_locale)).to be true + end + it "should store the resource passed to new as new_resource" do @provider.new_resource.should eql(@resource) end |