From de14cd7ae875181b8ab38708708d41d623d907e6 Mon Sep 17 00:00:00 2001 From: Rhys Campbell Date: Wed, 10 Apr 2019 18:12:30 +0200 Subject: [PATCH] Minor change to excep handling for 4.0 (#53484) --- lib/ansible/modules/database/mongodb/mongodb_shard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/database/mongodb/mongodb_shard.py b/lib/ansible/modules/database/mongodb/mongodb_shard.py index 0a7973d3a44..8dc67b1690a 100644 --- a/lib/ansible/modules/database/mongodb/mongodb_shard.py +++ b/lib/ansible/modules/database/mongodb/mongodb_shard.py @@ -289,7 +289,7 @@ def main(): try: client['admin'].command('listDatabases', 1.0) # if this throws an error we need to authenticate except Exception as excep: - if "not authorized on" in str(excep): + if "not authorized on" in str(excep) or "command listDatabases requires authentication" in str(excep): if login_user is not None and login_password is not None: client.admin.authenticate(login_user, login_password, source=login_database) else: