mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #295 from jhoekx/user-existing-groups
Group order in user module should not matter.
This commit is contained in:
commit
fe90650311
1 changed files with 4 additions and 3 deletions
|
@ -135,11 +135,12 @@ def user_mod(user, **kwargs):
|
||||||
cmd.append('-g')
|
cmd.append('-g')
|
||||||
cmd.append(kwargs[key])
|
cmd.append(kwargs[key])
|
||||||
elif key == 'groups' and kwargs[key] is not None:
|
elif key == 'groups' and kwargs[key] is not None:
|
||||||
for g in kwargs[key].split(','):
|
defined_groups = kwargs[key].split(',')
|
||||||
|
for g in defined_groups:
|
||||||
if not group_exists(g):
|
if not group_exists(g):
|
||||||
fail_json(msg="Group %s does not exist" % (g))
|
fail_json(msg="Group %s does not exist" % (g))
|
||||||
groups = ",".join(user_group_membership(user))
|
existing_groups = user_group_membership(user)
|
||||||
if groups != kwargs[key]:
|
if sorted(defined_groups) != sorted(existing_groups):
|
||||||
cmd.append('-G')
|
cmd.append('-G')
|
||||||
cmd.append(kwargs[key])
|
cmd.append(kwargs[key])
|
||||||
elif key == 'comment':
|
elif key == 'comment':
|
||||||
|
|
Loading…
Reference in a new issue