The playbook below
- name: test with json_query 1/2
hosts: localhost
vars:
domain_definition:
- name: server11
cluster: cluster1
port: '8080'
- name: server12
cluster: cluster2
port: '8090'
- name: server21
cluster: cluster3
port: '9080'
- name: server22
cluster: cluster4
port: '9090'
tasks:
- debug:
msg: "{{ domain_definition|
json_query('[?name==`server21`].port') }}"
gives
"msg": [
"9080"
]
HTH,
-vlado