On Tue, 13 Aug 2019 12:25:29 -0500 Amos <[email protected]> wrote: > This works for me: > > - name: populate service facts > service_facts: > > - name: populate running services into a list > set_fact: > services_running: "{{ services_running|default([]) + [ item ] }}" > loop: "{{ services.keys() | flatten(1) }}" > when: services[item].state == 'running' > > This is with Ansible 2.8.0 on RHEL 7.6
Right. Next option might be the filters below
- set_fact:
srv_running: "{{ services|dict2items|
selectattr('value.state', 'match', 'running')|
map(attribute='key')|
list }}"
Cheers,
-vlado
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20190813212838.0ed016b8%40gmail.com.
pgpsrUuLFrb8Y.pgp
Description: OpenPGP digital signature
