diff options
author | sersut <serdar@opscode.com> | 2013-11-19 11:18:52 -0800 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2013-11-19 11:59:04 -0800 |
commit | 999ba3350c8e9cc60d3ab32481d7e1149707c4bf (patch) | |
tree | e21f93a16171aa43818e697960d285707ddeeccc /lib/chef/provider | |
parent | 689ed8148cb0212ffe269b1d78a720c6c96a7ff7 (diff) | |
download | chef-999ba3350c8e9cc60d3ab32481d7e1149707c4bf.tar.gz |
Fix specs on FreeBSD.
Diffstat (limited to 'lib/chef/provider')
-rw-r--r-- | lib/chef/provider/group/pw.rb | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/lib/chef/provider/group/pw.rb b/lib/chef/provider/group/pw.rb index 2ba117d872..3ec6f6f668 100644 --- a/lib/chef/provider/group/pw.rb +++ b/lib/chef/provider/group/pw.rb @@ -39,16 +39,28 @@ class Chef def create_group command = "pw groupadd" command << set_options - command << set_members_option - run_command(:command => command) + member_options = set_members_options + if member_options.empty? + run_command(:command => command) + else + member_options.each do |option| + run_command(:command => command + option) + end + end end # Manage the group when it already exists def manage_group command = "pw groupmod" command << set_options - command << set_members_option - run_command(:command => command) + member_options = set_members_options + if member_options.empty? + run_command(:command => command) + else + member_options.each do |option| + run_command(:command => command + option) + end + end end # Remove the group @@ -70,22 +82,22 @@ class Chef end # Set the membership option depending on the current resource states - def set_members_option - opt = "" - + def set_members_options + opts = [ ] + members_to_be_added = [ ] + members_to_be_removed = [ ] + if @new_resource.append # Append is set so we will only add members given in the # members list and remove members given in the # excluded_members list. if @new_resource.members && !@new_resource.members.empty? - members_to_be_added = [ ] @new_resource.members.each do |member| members_to_be_added << member if !@current_resource.members.include?(member) end end if @new_resource.excluded_members && !@new_resource.excluded_members.empty? - members_to_be_removed = [ ] @new_resource.excluded_members.each do |member| members_to_be_removed << member if @current_resource.members.include?(member) end @@ -94,7 +106,6 @@ class Chef # Append is not set so we're resetting the membership of # the group to the given members. members_to_be_added = @new_resource.members - members_to_be_removed = [ ] @current_resource.members.each do |member| # No need to re-add a member if it's present in the new # list of members @@ -108,15 +119,15 @@ class Chef unless members_to_be_added.empty? Chef::Log.debug("#{@new_resource} adding group members: #{members_to_be_added.join(',')}") - opt << " -M #{members_to_be_added.join(',')}" + opts << " -m #{members_to_be_added.join(',')}" end - + unless members_to_be_removed.empty? Chef::Log.debug("#{@new_resource} removing group members: #{members_to_be_removed.join(',')}") - opt << " -d #{members_to_be_removed.join(',')}" + opts << " -d #{members_to_be_removed.join(',')}" end - - opt + + opts end end |