Skip to content

Commit

Permalink
Merge branch 'CHEF-1767'
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsdeleo committed Mar 18, 2011
2 parents eac7c3a + b4684d3 commit 96529ad
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 5 deletions.
5 changes: 5 additions & 0 deletions chef/lib/chef/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ def platforms
:group => Chef::Provider::Group::Usermod
}
},
:aix => {
:default => {
:group => Chef::Provider::Group::Aix
}
},
:default => {
:file => Chef::Provider::File,
:directory => Chef::Provider::Directory,
Expand Down
70 changes: 70 additions & 0 deletions chef/lib/chef/provider/group/aix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# 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 << " #{@new_resource.group_name}"
run_command(:command => command)
modify_group_members
end

def manage_group
command = "chgroup"
options = set_options
#Usage: chgroup [-R load_module] "attr=value" ... group
if options.size > 0
command << options << " #{@new_resource.group_name}"
run_command(:command => command)
end
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
end

end
end
end
end
11 changes: 7 additions & 4 deletions chef/lib/chef/provider/group/groupadd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ class Provider
class Group
class Groupadd < Chef::Provider::Group

def load_current_resource
super

def required_binaries
[ "/usr/sbin/groupadd",
"/usr/sbin/groupmod",
"/usr/sbin/groupdel" ].each do |required_binary|
"/usr/sbin/groupdel" ]
end

def load_current_resource
super
required_binaries.each do |required_binary|
raise Chef::Exceptions::Group, "Could not find binary #{required_binary} for #{@new_resource}" unless ::File.exists?(required_binary)
end
end
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/provider/group/usermod.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def load_current_resource

def modify_group_members
case node[:platform]
when "openbsd", "netbsd"
when "openbsd", "netbsd", "aix"
append_flags = "-G"
when "solaris"
append_flags = "-a -G"
Expand Down
1 change: 1 addition & 0 deletions chef/lib/chef/providers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
require 'chef/provider/user/useradd'
require 'chef/provider/user/windows'

require 'chef/provider/group/aix'
require 'chef/provider/group/dscl'
require 'chef/provider/group/gpasswd'
require 'chef/provider/group/groupadd'
Expand Down

0 comments on commit 96529ad

Please sign in to comment.