I have problem to filter array from output that i've got from some module. So this below is the output of the module that i have put it to some variable, and then i want to show/print only specific value from this variable. Maybe you guys can help me?
{
"extraConfig": [
{
"_vimtype": "vim.option.OptionValue",
"key": "svga.guestBackedPrimaryAware",
"value": "TRUE"
},
{
"_vimtype": "vim.option.OptionValue",
"key": "guestOS.detailed.data",
"value": "bitness='64' distroName='Red Hat Enterprise Linux' distroVersion='8.2' familyName='Linux' kernelVersion='4.18.0-193.el8.x86_64' prettyName='Red Hat Enterprise Linux 8.2 (Ootpa)'"
}
]
}
This above is the value of variable summary, then i want to get only prettyName='Red Hat Enterprise Linux 8.2 (Ootpa)', is it possible?
I have tried using ?contains but still got empty value, then i tried this below but got error:
fatal: [localhost]: FAILED! => {"msg": "Error in jmespath.search in json_query filter plugin:\n'method' object is not iterable"}
- debug:
msg: "{{ vmhost_info | json_query(query) }}"
vars:
keyvar: 'guestOS.detailed.data'
query: "instance.config.extraConfig[?key == '{{ keyvar }}'].value"