I am using the yum module in ansible to list all updates on a system. The output is something like this:
results: [
{
"name": "rubygem-ffi",
"nevra": "0:rubygem-ffi-1.9.10-2.el7.x86_64",
"repo": "epel",
"epoch": "0",
"version": "1.9.10",
"release": "2.el7",
"yumstate": "available",
"arch": "x86_64"
}
{
"name": "some-package",
"nevra": "blah",
"repo": "epel",
"epoch": "0",
"version": "6",
"release": "6.el7",
"yumstate": "available",
"arch": "x86_64"
}
]
And the code I use in tasks is:
- name: yum list
yum: list=updates
register: output
What I want is to print a debug message only when the name of a package is found in the JSON output. Like this:
- debug: msg="Found it!"
when: [output.I don't know the right filter] == "rubygem-ffi"
I tried something like output.results.name or output.results|map(attribute='name')|list but they don't seem to work
Any clues?