Dear All,
Can anyone please let me know how to use a register variable in JSON.
Where JSON is passed as an argument to a command using command module.
Any help or assistance would be highly appreciated.
Thanks,
Alok
Dear All,
Can anyone please let me know how to use a register variable in JSON.
Where JSON is passed as an argument to a command using command module.
Any help or assistance would be highly appreciated.
Thanks,
Alok
Something like this should work:
[wani@linux tmp ]$ cat a.yaml
- hosts: localhost
tasks:
- command: 'echo {\"key\": \"value\"}'
register: my_output
- debug:
msg: "{{ my_output.stdout | from_json }}"
On, run, it will show:
TASK [debug] ********************************************************************************************************************************************************************************
task path: /tmp/a.yaml:7
ok: [localhost] => {
"changed": false,
"msg": {
"key": "value"
}
}