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?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/588a1daa-af70-4441-99f2-dc9617d4ff5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.