-
Notifications
You must be signed in to change notification settings - Fork 23.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RabbitMQ user configuration fails due to sorting list of dicts #49120
Comments
Hi @groggi, thank you for submitting this issue! |
Files identified in the description: If these files are inaccurate, please update the |
This seems to be an issue due to the use of Python3. In Python2 the Example: a = [{'vhost': 'vhost', 'configure_priv': 'configure', 'write_priv': 'write', 'read_priv': 'read'}, {'vhost': '/', 'configure_priv': '.*', 'write_priv': '.*', 'read_priv': '.*'}]
print(sorted(a)) # works with Python 2.7.13 and does not with Python 3.5 |
This is a problem with python 2.7.15 as well. I've tested against multiple versions of ansible (2.7.1, 2.7.2 and even 2.5.11). Seems the module can create the users and set the permissions but followup runs are not idempotent and blow up with: "msg": "Virtual host 'vhost' does not exist", "rc": 65, "stderr": "Virtual host 'vhost' does not exist\n", "stderr_lines": ["Virtual host 'vhost' does not exist"], "stdout": "", "stdout_lines": []} |
Hey @windowsrefund you just made my week! Thank you. I was thinking I'm going mad for not finding out where the vhost "vhost" is coming from and why my deployments fail. So its also likely due to or at least connected to |
SUMMARY
Configuring RabbitMQ user fails due to trying to sort a list of RabbitMQ permission
dict
s in Python.Assumed to be due to #22507 (4522a53).
ISSUE TYPE
COMPONENT NAME
rabbitmq_user
ANSIBLE VERSION
Tested with multiple versions (some details redacted with
user
). First one is mine and used for the following examples/outputs.CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
The following task is executed:
EXPECTED RESULTS
The expected result is to see the user being present and configured in RabbitMQ.
ACTUAL RESULTS
A Python exception is caught and the playbook execution stops.
Debugging / Search for Cause
I added
import pdb; pdb.set_trace()
toansible/lib/ansible/modules/messaging/rabbitmq_user.py
Line 236 in 4522a53
As we can see
self._permissions
is a list of dictionaries and the method sorts that list before it compares it to the sorted list ofself.permissions
. However, Python is unable to sort a list ofdict
s as they have no natural order.The text was updated successfully, but these errors were encountered: