Skip to content

Commit

Permalink
Fixes ansible#5010 Add user to all defined supplementary groups
Browse files Browse the repository at this point in the history
  • Loading branch information
jctanner committed Nov 25, 2013
1 parent d308aa5 commit d187066
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/system/user
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class User(object):
if current_groups and not self.append:
groups_need_mod = True
else:
groups = self.get_groups_set()
groups = self.get_groups_set(remove_existing=False)
group_diff = set(current_groups).symmetric_difference(groups)

if group_diff:
Expand Down Expand Up @@ -429,15 +429,15 @@ class User(object):
else:
return list(grp.getgrnam(group))

def get_groups_set(self):
def get_groups_set(self, remove_existing=True):
if self.groups is None:
return None
info = self.user_info()
groups = set(self.groups.split(','))
for g in set(groups):
if not self.group_exists(g):
self.module.fail_json(msg="Group %s does not exist" % (g))
if info and self.group_info(g)[2] == info[3]:
if info and remove_existing and self.group_info(g)[2] == info[3]:
groups.remove(g)
return groups

Expand Down

0 comments on commit d187066

Please sign in to comment.