Hope this helps
server]$ ansible-playbook test-json-output.yml
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
PLAY [Ansible connection] ************************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [localhost]
PLAY [Read local Mailgun JSON file] **************************************************************************************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Create dictionary] *************************************************************************************************************************************************************************************
ok: [localhost]
TASK [Print variable JSON data] ******************************************************************************************************************************************************************************
ok: [localhost] => {
"jsondata": {
},
"receiving_dns_records": [
{
"cached": [],
"priority": "10",
"record_type": "MX",
"valid": "unknown",
"value": "
mxa.mailgun.org"
},
TASK [Output specific JSON data] *****************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "Error in jmespath.search in json_query filter plugin:\n'dict object' has no attribute '