Json parsing in Ansible


I have to parse the output of the following command:

which gives output as follows:

I need to parse the above output to check the value of “ismaster” is true. Please let me know how i can do this in ansible.

At the moment i am simply checking that the text “ismaster” : true is shown in the output using the following code:

However it would be nice to use Ansible’s json processing to check the same. Please advise.


There are quite a bit of helpful filters in Ansible.

Try: when: (output_text.stdout | from_json).ismaster

Leave a Reply