From aa6aedf26cf1836423e3eb144f87a755ce63763c Mon Sep 17 00:00:00 2001 From: Lujeni Date: Tue, 20 Sep 2016 16:19:53 +0200 Subject: [PATCH] Improve mongodb_user exception (#2962) - Better error message --- lib/ansible/modules/extras/database/misc/mongodb_user.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/extras/database/misc/mongodb_user.py b/lib/ansible/modules/extras/database/misc/mongodb_user.py index b0bfe9334c4..266b902fda7 100644 --- a/lib/ansible/modules/extras/database/misc/mongodb_user.py +++ b/lib/ansible/modules/extras/database/misc/mongodb_user.py @@ -343,7 +343,7 @@ def main(): module.fail_json(msg='The localhost login exception only allows the first admin account to be created') #else: this has to be the first admin user added - except ConnectionFailure, e: + except Exception, e: module.fail_json(msg='unable to connect to database: %s' % str(e)) check_compatibility(module, client) @@ -363,7 +363,7 @@ def main(): module.exit_json(changed=True, user=user) user_add(module, client, db_name, user, password, roles) - except OperationFailure, e: + except Exception, e: module.fail_json(msg='Unable to add or update user: %s' % str(e)) # Here we can check password change if mongo provide a query for that : https://jira.mongodb.org/browse/SERVER-22848 @@ -374,7 +374,7 @@ def main(): elif state == 'absent': try: user_remove(module, client, db_name, user) - except OperationFailure, e: + except Exception, e: module.fail_json(msg='Unable to remove user: %s' % str(e)) module.exit_json(changed=True, user=user)