LOGBOOK

HELP

Quiz Entry - updated: 2026.12.01

What does the JMESPath query ansible_facts.*.objects[*].[type,name,color] do, and why must a field like task-details be written as "task-details"?

It goes into ansible_facts, takes every child (*), from each takes every element of objects ([*]), and builds a small list [type, name, color] per object. Names containing a dash must be quoted, because an unquoted identifier may only contain letters, digits and underscores.

json_query (from community.general, which needs the Python package jmespath installed) runs a JMESPath expression against a variable:

Piece Meaning
a.b field b inside a
* every value of an object, whatever its key (an object wildcard)
list[*] every element of a list, and apply the rest to each (a projection)
list[0] only the first element
[type,name,color] build a new list from these fields (a multiselect)
"task-details" a quoted identifier, required for names with -

Without quotes, task-details would be parsed as task minus details and fail. In YAML the whole query sits in single quotes, so the double quotes survive: query: '"run-script".*.tasks[*]."task-details"[0].statusDescription'.

The * is also handy when you don't know (or don't want to depend on) a key's exact name: ansible_facts.*.objects works whatever the facts key is called.

Go deeper:

From Quiz: ITIA / Network Automation with Ansible and a Check Point Firewall | Updated: Dec 01, 2026