summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto C. Morano <rcmorano@emergya.com>2012-01-09 14:18:53 +0100
committerBryan McLellan <btm@opscode.com>2012-02-09 11:49:37 -0800
commit248654f8cd065946d43c25f946d24c30ee895550 (patch)
tree99468df665f4ce569742c1ece4ca00673edc7de1
parentb463a43b39911abbc4b124bf1d80893da65a0e76 (diff)
downloadchef-248654f8cd065946d43c25f946d24c30ee895550.tar.gz
added support to set empty groups
-rw-r--r--chef/lib/chef/provider/group/gpasswd.rb23
1 files changed, 14 insertions, 9 deletions
diff --git a/chef/lib/chef/provider/group/gpasswd.rb b/chef/lib/chef/provider/group/gpasswd.rb
index 6dfe597179..78100dcec3 100644
--- a/chef/lib/chef/provider/group/gpasswd.rb
+++ b/chef/lib/chef/provider/group/gpasswd.rb
@@ -33,19 +33,24 @@ class Chef
end
def modify_group_members
- unless @new_resource.members.empty?
if(@new_resource.append)
- @new_resource.members.each do |member|
- Chef::Log.debug("#{@new_resource} appending member #{member} to group #{@new_resource.group_name}")
- shell_out!("gpasswd -a #{member} #{@new_resource.group_name}")
+ unless @new_resource.members.empty?
+ @new_resource.members.each do |member|
+ Chef::Log.debug("#{@new_resource} appending member #{member} to group #{@new_resource.group_name}")
+ shell_out!("gpasswd -a #{member} #{@new_resource.group_name}")
+ end
+ else
+ Chef::Log.debug("#{@new_resource} not changing group members, the group has no members to add")
end
else
- Chef::Log.debug("#{@new_resource} setting group members to #{@new_resource.members.join(', ')}")
- shell_out!("gpasswd -M #{@new_resource.members.join(',')} #{@new_resource.group_name}")
+ unless @new_resource.members.empty?
+ Chef::Log.debug("#{@new_resource} setting group members to #{@new_resource.members.join(', ')}")
+ shell_out!("gpasswd -M #{@new_resource.members.join(',')} #{@new_resource.group_name}")
+ else
+ Chef::Log.debug("#{@new_resource} setting group members to: none")
+ shell_out!("gpasswd -M \"\" #{@new_resource.group_name}")
+ end
end
- else
- Chef::Log.debug("#{@new_resource} not changing group members, the group has no members")
- end
end
end
end