mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 19:20:22 -07:00
re-add idempotency check
This commit is contained in:
parent
6e81f41cd4
commit
6a321fe346
1 changed files with 10 additions and 0 deletions
|
@ -48,6 +48,7 @@ options:
|
||||||
required: false
|
required: false
|
||||||
default: 27017
|
default: 27017
|
||||||
replica_set:
|
replica_set:
|
||||||
|
version_added: "1.6"
|
||||||
description:
|
description:
|
||||||
- Replica set to connect to (automatically connects to primary for writes)
|
- Replica set to connect to (automatically connects to primary for writes)
|
||||||
required: false
|
required: false
|
||||||
|
@ -196,6 +197,15 @@ def main():
|
||||||
else:
|
else:
|
||||||
client = MongoClient(login_host, int(login_port))
|
client = MongoClient(login_host, int(login_port))
|
||||||
|
|
||||||
|
# try to authenticate as a target user to check if it already exists
|
||||||
|
try:
|
||||||
|
client[db_name].authenticate(user, password)
|
||||||
|
if state == 'present':
|
||||||
|
module.exit_json(changed=False, user=user)
|
||||||
|
except OperationFailure:
|
||||||
|
if state == 'absent':
|
||||||
|
module.exit_json(changed=False, user=user)
|
||||||
|
|
||||||
if login_user is None and login_password is None:
|
if login_user is None and login_password is None:
|
||||||
mongocnf_creds = load_mongocnf()
|
mongocnf_creds = load_mongocnf()
|
||||||
if mongocnf_creds is not False:
|
if mongocnf_creds is not False:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue