Skip to content

Commit

Permalink
[CHEF-1767] Group::Aix subclasses Chef::Provider::Group::Usermod to r…
Browse files Browse the repository at this point in the history
…euse modify_group_members.

Group::Aix overrides all methods in Group::Groupadd except for load_current_resource.
The Group::Aix code is very similar to Group::Groupadd, diffs are:
 /usr/bin/mkgroup  instead of /usr/sbin/groupadd
 /usr/bin/chgroup  instead of /usr/sbin/groupmod
 /usr/sbin/rmgroup instead of /usr/sbin/groupdel

 args when specifying gid: 'id=$gid' instead of '-g $gid'
  • Loading branch information
dougm authored and danielsdeleo committed Mar 18, 2011
1 parent 97bfda6 commit 3cddfb0
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions chef/lib/chef/provider/group/aix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#
# Author:: Doug MacEachern (<[email protected]>)
# Copyright:: Copyright (c) 2010 VMware, 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 'chef/provider/group/usermod'

class Chef
class Provider
class Group
class Aix < Chef::Provider::Group::Usermod

def required_binaries
[ "/usr/bin/mkgroup",
"/usr/bin/chgroup",
"/usr/sbin/rmgroup" ]
end

def create_group
command = "mkgroup"
command << set_options
run_command(:command => command)
modify_group_members
end

def manage_group
command = "chgroup"
command << set_options
run_command(:command => command)
modify_group_members
end

def remove_group
run_command(:command => "rmgroup #{@new_resource.group_name}")
end

def set_options
opts = ""
{ :gid => "id" }.sort { |a,b| a[0] <=> b[0] }.each do |field, option|
if @current_resource.send(field) != @new_resource.send(field)
if @new_resource.send(field)
Chef::Log.debug("#{@new_resource}: setting #{field.to_s} to #{@new_resource.send(field)}")
opts << " '#{option}=#{@new_resource.send(field)}'"
end
end
end
opts << " #{@new_resource.group_name}"
end

end
end
end
end

0 comments on commit 3cddfb0

Please sign in to comment.