Hello All,

I need to monitor MongoDB replica set using Ansible, I have created below 
playbook, i need some guidance  on the same, if some one has done this 
before please help.
---
- name: check the MongoDB replicaset status
  hosts: mongodb1
  become: yes
  become_method: su
  tasks:
    - name: check for the status of MongoDB
      community.mongodb.mongodb_status:
        replica_set: rs0
        poll: 5
        interval: 10
        when: ansible_hostname == "mongodb1"
      register: rs_status

    - name: send email notification based on Replica set status
      mail:
        host: xxx.xxx.xxx.xxx
        port: xxxxxxxx
        sender: ''
        to: ''
        subject: 'Report for replicaset'
        body: ''
      delegate_to: 
      when:  (rs_status != "PRIMARY" ) or (rs_status != "SECONDARY") or 
(rs_status != "ARBITER" )

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c85bc0f1-37c4-4df6-9157-97e77955b3a6n%40googlegroups.com.

Reply via email to