I would not use ansible for this purpose at all, so I don't think it looks "allrite" :) If you have actual errors/issues with running the playbook then we have something tangible. I wonder why you have not even tested it...?
On Thu, 14 Sept 2023 at 21:59, Amit Kulkarni <[email protected]> wrote: > Hello Dick, > > Thanks for the response. > > We are trying to do monitoring with Splunk but as of now we are sure if we > can query to the admin DB and get the output of command rs.status(), in > splunk. > > That's why I am thinking of having this playbook as an alternative > arrangement. > > I have not tested it yet but happy to get feedback on the playbook, if > it's looking allrite > > Regards > Amit > > On Thu, Sep 14, 2023 at 3:45 PM Dick Visser <[email protected]> wrote: > >> >> Sent from Gmail Mobile >> >> >> On Thu, 14 Sep 2023 at 18:45, Amit Kulkarni <[email protected]> >> wrote: >> >>> Hello All, >>> >>> I need to monitor MongoDB replica set using Ansible >>> >> >> >> How is this monitoring supposed to happen? I'm asking because ansible is >> a configuration management tool. Monitoring is usually done with monitoring >> tools. >> >> I have created below playbook, i need some guidance on the same >>> >> >> What is the problem/error you encounter? >> >> >> >> 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 >>> <https://groups.google.com/d/msgid/ansible-project/c85bc0f1-37c4-4df6-9157-97e77955b3a6n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> 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/CAF8BbLa2Kj6wM_RuEffucW3m2KhkDV9BmXvheA99X0CavPpcMg%40mail.gmail.com >> <https://groups.google.com/d/msgid/ansible-project/CAF8BbLa2Kj6wM_RuEffucW3m2KhkDV9BmXvheA99X0CavPpcMg%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > 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/CAON3ZR20gx43YF-6NiD7skL-tuxuXZL8OzCNSHyE84jvKof_4g%40mail.gmail.com > <https://groups.google.com/d/msgid/ansible-project/CAON3ZR20gx43YF-6NiD7skL-tuxuXZL8OzCNSHyE84jvKof_4g%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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/CAF8BbLahrHecNCDMtcYSu2dFT2-3vK6M41t2vtZcD8pC0PDHuw%40mail.gmail.com.
