I have a collection of registered shell commands captured and would like to be able to count how many match a pattern:
`
- name: run a shell command to produce ‘a’ or ‘b’ on all boxes and collect the results
run_once: true
shell: return_a_or_b.sh
register: shell_output_collection
with_items: play_hosts
delegate_to: 127.0.0.1
`
Think it’s a matter of using a filter and then a length filter after it but I can’t quite crack it:
`
- name: count how many are ‘a’
set_fact: count_of_a=“{{ shell_output_collection.results | map(attribute=‘stdout’) | ???match if value is ‘a’??? | list | length }}”
`
The ‘equalto’ test is still in the jinja dev branch afaict and it’s not even certain that that will help.
How else can this be accomplished?