mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-30 01:41:45 -07:00
Code was adding '-a' even when the user was already in the desired groups causing usermod to fail since there was no '-G' option. This is duplicate code (3 lines) from the 'group' section, so could be improved, but it works.
This commit is contained in:
parent
dcbe48e2d4
commit
d814136ec9
1 changed files with 4 additions and 1 deletions
|
@ -162,6 +162,9 @@ def user_mod(user, **kwargs):
|
||||||
elif key == 'append':
|
elif key == 'append':
|
||||||
if kwargs[key] is not None and kwargs[key] == 'yes':
|
if kwargs[key] is not None and kwargs[key] == 'yes':
|
||||||
if 'groups' in kwargs and kwargs['groups'] is not None:
|
if 'groups' in kwargs and kwargs['groups'] is not None:
|
||||||
|
defined_groups = kwargs['groups'].split(',')
|
||||||
|
existing_groups = user_group_membership(user)
|
||||||
|
if sorted(defined_groups) != sorted(existing_groups):
|
||||||
cmd.append('-a')
|
cmd.append('-a')
|
||||||
# skip if no changes to be made
|
# skip if no changes to be made
|
||||||
if len(cmd) == 1:
|
if len(cmd) == 1:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue