summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2021-12-03 15:48:08 -0800
committerTim Smith <tsmith84@gmail.com>2021-12-03 15:48:08 -0800
commitfb78658252330a946834c9c3c503c6ffb6758e85 (patch)
treefa65fad783ce2ee6da01144b68d9a688911d61e2
parent5f85c0515e9d46a46fec123a8b8e19a94a3e37af (diff)
downloadchef-eol_suse.tar.gz
Remove group provider for EOL SLES < 12eol_suse
The only supported versions of SLES are 12 and 15 at this point. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/group/suse.rb82
-rw-r--r--lib/chef/providers.rb1
-rw-r--r--spec/unit/provider/group/suse_spec.rb90
3 files changed, 0 insertions, 173 deletions
diff --git a/lib/chef/provider/group/suse.rb b/lib/chef/provider/group/suse.rb
deleted file mode 100644
index 266e8e0fbc..0000000000
--- a/lib/chef/provider/group/suse.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# Author:: AJ Christensen (<aj@chef.io>)
-# Copyright:: Copyright (c) Chef Software Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require_relative "groupadd"
-require "etc" unless defined?(Etc)
-
-class Chef
- class Provider
- class Group
- class Suse < Chef::Provider::Group::Groupadd
- provides :group, platform: "suse", platform_version: "< 12.0"
-
- def load_current_resource
- super
- end
-
- def define_resource_requirements
- super
- requirements.assert(:all_actions) do |a|
- a.assertion { ::File.exist?("/usr/sbin/groupmod") }
- a.failure_message Chef::Exceptions::Group, "Could not find binary /usr/sbin/groupmod for #{new_resource.name}"
- # No whyrun alternative: this component should be available in the base install of any given system that uses it
- end
-
- requirements.assert(:create, :manage, :modify) do |a|
- a.assertion do
-
- to_add(new_resource.members).all? { |member| Etc.getpwnam(member) }
- rescue
- false
-
- end
- a.failure_message Chef::Exceptions::Group, "Could not add users #{to_add(new_resource.members).join(", ")} to #{new_resource.group_name}: one of these users does not exist"
- a.whyrun "Could not find one of these users: #{to_add(new_resource.members).join(", ")}. Assuming it will be created by a prior step"
- end
- end
-
- def set_members(members)
- to_remove(members).each do |member|
- remove_member(member)
- end
-
- to_add(members).each do |member|
- add_member(member)
- end
- end
-
- def to_add(members)
- members - current_resource.members
- end
-
- def add_member(member)
- shell_out!("groupmod", "-A", member, new_resource.group_name)
- end
-
- def to_remove(members)
- current_resource.members - members
- end
-
- def remove_member(member)
- shell_out!("groupmod", "-R", member, new_resource.group_name)
- end
-
- end
- end
- end
-end
diff --git a/lib/chef/providers.rb b/lib/chef/providers.rb
index ac470125e7..e713383190 100644
--- a/lib/chef/providers.rb
+++ b/lib/chef/providers.rb
@@ -108,7 +108,6 @@ require_relative "provider/group/groupadd"
require_relative "provider/group/groupmod"
require_relative "provider/group/pw"
require_relative "provider/group/solaris"
-require_relative "provider/group/suse"
require_relative "provider/group/usermod"
require_relative "provider/group/windows"
diff --git a/spec/unit/provider/group/suse_spec.rb b/spec/unit/provider/group/suse_spec.rb
deleted file mode 100644
index 0e04e5bd2e..0000000000
--- a/spec/unit/provider/group/suse_spec.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-#
-# Author:: Tom Duffield (<tom@chef.io>)
-# Copyright:: Copyright (c) Chef Software Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require "spec_helper"
-
-describe Chef::Provider::Group::Suse do
- let(:node) { Chef::Node.new }
- let(:events) { Chef::EventDispatch::Dispatcher.new }
- let(:run_context) { Chef::RunContext.new(node, {}, events) }
- let(:new_members) { %w{root new_user} }
- let(:new_resource) do
- Chef::Resource::Group.new("new_group").tap do |r|
- r.gid 50
- r.members new_members
- r.system false
- r.non_unique false
- end
- end
- let(:current_resource) do
- Chef::Resource::Group.new("new_group").tap do |r|
- r.gid 50
- r.members %w{root}
- r.system false
- r.non_unique false
- end
- end
- let(:provider) do
- described_class.new(new_resource, run_context).tap do |p|
- p.current_resource = current_resource
- end
- end
-
- describe "when determining the current group state" do
- before(:each) do
- allow(File).to receive(:exist?).and_return(true)
- provider.action = :create
- provider.define_resource_requirements
- end
-
- # Checking for required binaries is already done in the spec
- # for Chef::Provider::Group - no need to repeat it here. We'll
- # include only what's specific to this provider.
- it "should raise an error if the required binary /usr/sbin/groupmod doesn't exist" do
- expect(File).to receive(:exist?).with("/usr/sbin/groupmod").and_return(false)
- expect { provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
- end
-
- it "should raise error if one of the member users does not exist" do
- expect(Etc).to receive(:getpwnam).with("new_user").and_raise ArgumentError
- expect { provider.process_resource_requirements }.to raise_error(Chef::Exceptions::Group)
- end
- end
-
- describe "#set_members" do
- it "should add missing members and remove deleted members" do
- expect(provider).not_to receive(:remove_member)
- expect(provider).to receive(:add_member).with("new_user")
- provider.set_members(new_members)
- end
- end
-
- describe "#add_member" do
- it "should call out to groupmod to add user" do
- expect(provider).to receive(:shell_out_compacted!).with("groupmod", "-A", "new_user", "new_group")
- provider.add_member("new_user")
- end
- end
-
- describe "#remove_member" do
- it "should call out to groupmod to remove user" do
- expect(provider).to receive(:shell_out_compacted!).with("groupmod", "-R", "new_user", "new_group")
- provider.remove_member("new_user")
- end
- end
-end