diff options
author | Doug MacEachern <dougm@vmware.com> | 2010-10-13 16:49:46 -0700 |
---|---|---|
committer | Daniel DeLeo <dan@opscode.com> | 2011-03-18 14:28:55 -0700 |
commit | 3cddfb05ebd0b8e6d832eed3ace84639dcf21da5 (patch) | |
tree | 8d851363ffb890d862ec5a2e02e288a612b346a1 | |
parent | 97bfda6d7312c84cd925cb8eb2f1d86a9f4af37e (diff) | |
download | chef-3cddfb05ebd0b8e6d832eed3ace84639dcf21da5.tar.gz |
[CHEF-1767] Group::Aix subclasses Chef::Provider::Group::Usermod to reuse 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'
-rw-r--r-- | chef/lib/chef/provider/group/aix.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/chef/lib/chef/provider/group/aix.rb b/chef/lib/chef/provider/group/aix.rb new file mode 100644 index 0000000000..163461d6f0 --- /dev/null +++ b/chef/lib/chef/provider/group/aix.rb @@ -0,0 +1,66 @@ +# +# Author:: Doug MacEachern (<dougm@vmware.com>) +# 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 |