Unable to parse JSON with YAML

I am trying to assign a variable corresponding to the IP address specified in the API call that I am making to an online provider.

Here are the JSON data I get:

TASK [manager : debug] ********************************************************* ok: [localhost] => { "msg": [ { "address": "10.0.3.224", "family": "inet", "netmask": "24", "scope": "global" }, { "address": "fe80::216:3eff:feb2:7330", "family": "inet6", "netmask": "64", "scope": "link" } ] } 

How can I parse the output of the first address and assign its value to a variable in YAML

that's what i tried

 - debug: msg={{ output.stdout|from_json }} 

but I can not get the IP address.

+8
source share
1 answer

Try: msg={{ (output.stdout | from_json | first).address }}

+10
source

Source: https://habr.com/ru/post/1011554/


All Articles