I have to parse the output of the following command:
mongo --eval \"db.isMaster()\"
which gives output as follows:
There are quite a bit of helpful filters in Ansible.
Try: when: (output_text.stdout | from_json).ismaster
when: (output_text.stdout | from_json).ismaster