I am new to Anisble and I have been trying to get Anisble to take the 
output of a local json file and read it, store the information and then 
output the data. I think I was successful because it does output the data 
in the file. What I am having trouble with is getting just a specific piece 
of data to display so I know Anisble is parsing the right section of the 
json file so I can pass it to a variable in the playbook. I feel I have 
tried almost everything but with no success.

JSON EXAMPLE
}, "receiving_dns_records": [ { "cached": [], "priority": "10", 
"record_type": "MX", "valid": "unknown", "value": "mxa.domain.org" }, 

Playbook:

---
- name: Ansible connection 
  hosts: localhost        
  connection: local 

- name: Read local JSON file
  hosts: localhost
  vars:
    jsondata: "{{ lookup('file', '/home/name/appdir/output.json') | 
from_json }}"
  
  tasks:
    - name: Create dictionary 
      set_fact: 
        jsondata: "{{ jsondata }}"

    
    - name: Print variable JSON data
      debug:
        var: jsondata
               


    - name: Output specific JSON data 
      debug: 
        msg: "this is where I get lost I have tried JMES Query and Debug 
MSG but every example I see fails"

-- 
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/f88ee7f8-e43b-45db-bd2d-77a3a8c50710n%40googlegroups.com.

Reply via email to