In the Ansible documentation on filters, the following example is shown, which executes a JSON query on a data structure, selecting certain fields name
and port
:
- name: "Display all server ports and names from cluster1"
debug: var=item
with_items: "{{domain_definition|json_query(server_query)}}"
vars:
server_query: "domain.server[?cluster=='cluster2'].{name: name, port: port}"
I managed to use this logic to parse the JSON response of a REST service, but I would like to not only print out the result, but reuse it several times again during my playbook.
How is it possible to persist the above variable var
for later use?