From 467d9a80906b09ea0dcf36be76fcfa7998d23d3d Mon Sep 17 00:00:00 2001 From: Guillaume Dufour Date: Fri, 26 Feb 2016 15:08:04 +0100 Subject: [PATCH] avoid problem with old mongo version without roles --- lib/ansible/modules/extras/database/misc/mongodb_user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/extras/database/misc/mongodb_user.py b/lib/ansible/modules/extras/database/misc/mongodb_user.py index 55f221981b..f9ac1fa363 100644 --- a/lib/ansible/modules/extras/database/misc/mongodb_user.py +++ b/lib/ansible/modules/extras/database/misc/mongodb_user.py @@ -278,7 +278,7 @@ def main(): uinfo = user_find(client, user, db_name) if update_password != 'always' and uinfo: password = None - if list(map((lambda x: x['role']), uinfo['roles'])) == roles: + if 'roles' in uinfo and list(map((lambda x: x['role']), uinfo['roles'])) == roles: module.exit_json(changed=False, user=user) if module.check_mode: