From 8227105f02aee3269e2a8b1a9232af670397985b Mon Sep 17 00:00:00 2001 From: Guillaume Dufour Date: Sun, 28 Feb 2016 07:25:45 +0100 Subject: [PATCH] fix #1747 mongodb_user support check mode --- lib/ansible/modules/extras/database/misc/mongodb_user.py | 8 +++++++- 1 file changed, 7 insertions(+), 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 979bf66cc99..3f87579fea4 100644 --- a/lib/ansible/modules/extras/database/misc/mongodb_user.py +++ b/lib/ansible/modules/extras/database/misc/mongodb_user.py @@ -183,6 +183,8 @@ def user_add(module, client, db_name, user, password, roles): def user_remove(module, client, db_name, user): exists = user_find(client, user) if exists: + if module.check_mode: + module.exit_json(changed=True, user=user) db = client[db_name] db.remove_user(user) else: @@ -222,7 +224,8 @@ def main(): roles=dict(default=None, type='list'), state=dict(default='present', choices=['absent', 'present']), update_password=dict(default="always", choices=["always", "on_create"]), - ) + ), + supports_check_mode=True ) if not pymongo_found: @@ -274,6 +277,9 @@ def main(): if update_password != 'always' and user_find(client, user): password = None + if module.check_mode: + module.exit_json(changed=True, user=user) + try: user_add(module, client, db_name, user, password, roles) except OperationFailure, e: