community.mongodb.mongodb_status – Validates the status of the cluster.¶
Note
This plugin is part of the community.mongodb collection (version 1.2.0).
To install it use: ansible-galaxy collection install community.mongodb
.
To use it in a playbook, specify: community.mongodb.mongodb_status
.
New in version 1.0.0: of community.mongodb
Synopsis¶
Validates the status of the cluster.
The module expects all replicaset nodes to be PRIMARY, SECONDARY or ARBITER.
Will wait until a timeout for the replicaset state to converge if required.
Can also be used to lookup the current PRIMARY member (see examples).
Parameters¶
Notes¶
Note
Requires the pymongo Python package on the remote host, version 2.4.2+. This can be installed using pip or the OS package manager. @see http://api.mongodb.org/python/current/installation.html
Examples¶
- name: Check replicaset is healthy, fail if not after first attempt
community.mongodb.mongodb_status:
replica_set: rs0
when: ansible_hostname == "mongodb1"
- name: Wait for the replicaset rs0 to converge, check 5 times, 10 second interval between checks
community.mongodb.mongodb_status:
replica_set: rs0
poll: 5
interval: 10
when: ansible_hostname == "mongodb1"
# Get the replicaset status and then lookup the primary's hostname and save to a variable
- name: Ensure replicaset is stable before beginning
community.mongodb.mongodb_status:
login_user: "{{ admin_user }}"
login_password: "{{ admin_user_password }}"
poll: 3
interval: 10
register: rs
- name: Lookup PRIMARY replicaset member
set_fact:
primary: "{{ item.key.split('.')[0] }}"
loop: "{{ lookup('dict', rs.replicaset) }}"
when: "'PRIMARY' in item.value"
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
Rhys Campbell (@rhysmeister)