Cannot figure this json_query out, I'm using Ansible and json_query to (try to) count all healthy targets in a targets group.
So I have this to get the info
- name: Query target group
elb_target_group_info:
names: my-target-group-name
collect_targets_health: true
register: target_group_info
Then I try to simply print the number of healthy targets, like this:
- name: Debug
debug:
msg: "{{ target_group_info | json_query('target_groups[*].targets_health_description[*].target_health[?state==''healthy'']') | length }}"
and I just get an empty list:
"msg": [
0
]
I've tried numerous different queries and now just fumbling around, not a clue. I'm interested in the json_query to get what I need, and also any tips how to quickly iterate testing json_query queries with mock input.
Many thanks!