seems close, but getting:

  msg: 'Invalid data passed to ''loop'', it requires a list, got this
instead: dict_keys([''abrt-xorg.service'', ''sshd-keygen.service'',
''systemd-machine-id-commit.service'', ''iprinit.servic
e'', ''systemd-readahead-collect.service'', ''puppet.service'',
''plymouth-kexec.service'', ''cgdcbxd.service'', ''console-shell.service'',
''rngd.service'', ''sssd-autofs.service'', .....



On Mon, Aug 12, 2019 at 3:26 PM Vladimir Botka <[email protected]> wrote:

> On Mon, 12 Aug 2019 14:57:16 -0500
> Amos <[email protected]> wrote:
>
> > I can't seem to get this syntax correct, and at least one reference I
> found
> > produced more errors.  I'd like to create a list of all running
> processes.
> >
> >     - name: populate running services into a list
> >       set_fact:
> >         services_running: >
> >           {%  if (hostvars[inventory_hostname]['services']['{{ item
> > }}']['state'] == 'running')  %}
> >                  services_running + [ '{{ item }}' ]
> >           {%  endif  %}
> >       with_items: "{{ hostvars[inventory_hostname]['services'].keys() }}"
> >
>
> Try this one
>
>      - name: populate running services into a list
>        set_fact:
>          services_running: "{{ services_running|default([]) + [ item ] }}"
>        loop: "{{ services.keys() }}"
>        when: services[item].state == 'running'
>
> 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/CAK2viQUjRgsoZ-j6JMbkrT%3D2tkQ%3DuhOFk5xhqjJdRdS2K1dJaw%40mail.gmail.com.

Reply via email to