From 4096d74245bae5f0828b4129c8a44154235195bf Mon Sep 17 00:00:00 2001 From: Gregor Wegberg Date: Fri, 30 Nov 2018 21:18:57 +0100 Subject: [PATCH] Specify key to use while sorting permissions (#49126) Without specifying the dictionary key to use while sorting it will fail in Python 3 environments due to simplifying Python's rules for ordering comparisons: https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons --- lib/ansible/modules/messaging/rabbitmq/rabbitmq_user.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/messaging/rabbitmq/rabbitmq_user.py b/lib/ansible/modules/messaging/rabbitmq/rabbitmq_user.py index c7fa7173a0..c7ba6f6d27 100644 --- a/lib/ansible/modules/messaging/rabbitmq/rabbitmq_user.py +++ b/lib/ansible/modules/messaging/rabbitmq/rabbitmq_user.py @@ -117,6 +117,7 @@ EXAMPLES = ''' write_priv: .* state: present ''' +import operator from ansible.module_utils.basic import AnsibleModule @@ -230,7 +231,8 @@ class RabbitMqUser(object): return set(self.tags) != set(self._tags) def has_permissions_modifications(self): - return sorted(self._permissions) != sorted(self.permissions) + sort_key_fetch = operator.itemgetter('vhost') + return sorted(self._permissions, key=sort_key_fetch) != sorted(self.permissions, key=sort_key_fetch) def main():