From 2c8fbdbd20e1cb50071317a09651b3e8c8f6afd0 Mon Sep 17 00:00:00 2001 From: Jeroen Hoekx Date: Wed, 2 May 2012 11:54:27 +0200 Subject: [PATCH] Group order in user module should not matter. Groups are not necessarily returned in the defined order, especially when the user already existed before ansible started managing the system. --- library/user | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/user b/library/user index cd631494dd..30fdda2112 100755 --- a/library/user +++ b/library/user @@ -135,11 +135,12 @@ def user_mod(user, **kwargs): cmd.append('-g') cmd.append(kwargs[key]) 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): fail_json(msg="Group %s does not exist" % (g)) - groups = ",".join(user_group_membership(user)) - if groups != kwargs[key]: + existing_groups = user_group_membership(user) + if sorted(defined_groups) != sorted(existing_groups): cmd.append('-G') cmd.append(kwargs[key]) elif key == 'comment':