Hi,
I have a json file called "develop.json" like below,
{
"releasedata": {
"release_name": "abcd",
"release_number": "22"
}
}
I want to read this file in ansible and get the value for "release_name" key. I have tried the below code
---
- hosts: localhost
vars:
version_file: "{{ lookup('file', '/opt/develop.json') | from_json }}"
tasks:
- name: print json file
debug: msg= "{{ version_file.releasedata.release_name }}"
But I am getting this error:
{"failed": true, "msg": "the field 'args' has an invalid value ([]), and could not be converted to an dict
So I am assuming this is not the right way to read a json file in ansible. Kindly tell me the right way to read a json file. Thank you.