mongodb_user: Ensure to close database connection (closes #59353) (#65665)

pull/65665/merge
Lujeni 5 years ago committed by GitHub
parent c9b38bd74e
commit 25181e1b70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -424,7 +424,11 @@ def main():
user_add(module, client, db_name, user, password, roles)
except Exception as e:
module.fail_json(msg='Unable to add or update user: %s' % to_native(e), exception=traceback.format_exc())
finally:
try:
client.close()
except Exception:
pass
# Here we can check password change if mongo provide a query for that : https://jira.mongodb.org/browse/SERVER-22848
# newuinfo = user_find(client, user, db_name)
# if uinfo['role'] == newuinfo['role'] and CheckPasswordHere:
@ -435,7 +439,11 @@ def main():
user_remove(module, client, db_name, user)
except Exception as e:
module.fail_json(msg='Unable to remove user: %s' % to_native(e), exception=traceback.format_exc())
finally:
try:
client.close()
except Exception:
pass
module.exit_json(changed=True, user=user)

Loading…
Cancel
Save