From 79d034b088117d1d00c44f993f5b95fca36c1116 Mon Sep 17 00:00:00 2001 From: Joel Diaz Date: Tue, 19 Sep 2017 09:10:21 -0400 Subject: [PATCH] update miq compare_user group comparison (#29063) When calling manageiq_user to an already existing user (but leaving out the password so that it doesn't automatically 're-create' the user), the module fails with: fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 127.0.0.1 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/tmp/ansible_Fr7Nt3/ansible_module_manageiq_user.py\", line 324, in \r\n main()\r\n File \"/tmp/ansible_Fr7Nt3/ansible_module_manageiq_user.py\", line 315, in main\r\n res_args = manageiq_user.edit_user(user, name, group, password, email)\r\n File \"/tmp/ansible_Fr7Nt3/ansible_module_manageiq_user.py\", line 229, in edit_user\r\n if self.compare_user(user, name, group_id, password, email):\r\n File \"/tmp/ansible_Fr7Nt3/ansible_module_manageiq_user.py\", line 189, in compare_user\r\n (group_id and user['group']['id'] != group_id)\r\nKeyError: 'group'\r\n", "msg": "MODULE FAILURE", "rc": 0} The 'group' field turns out to be 'current_group_id' (at least with ManageIQ 4.6). Update the comparison accordingly. --- lib/ansible/modules/remote_management/manageiq/manageiq_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/remote_management/manageiq/manageiq_user.py b/lib/ansible/modules/remote_management/manageiq/manageiq_user.py index de461fc3bc..083dde2533 100755 --- a/lib/ansible/modules/remote_management/manageiq/manageiq_user.py +++ b/lib/ansible/modules/remote_management/manageiq/manageiq_user.py @@ -192,7 +192,7 @@ class ManageIQUser(object): (name and user['name'] != name) or (password is not None) or (email and user['email'] != email) or - (group_id and user['group']['id'] != group_id) + (group_id and user['current_group_id'] != group_id) ) return not found_difference