backreference to 'all hosts in scope of current task'?

21 views
Skip to first unread message

Nusenu

unread,
Feb 22, 2015, 8:37:50 AM2/22/15
to ansible...@googlegroups.com
Hello,

I'd like to loop over all hosts that are in scope of the current task in
a template.

Currently I use a fixed groupname as seen in the following block, but
that will break if the scope doesn't match the groupname.

Is there a way to say loop over all hosts in scope of current task?

{% for host in groups['groupname'] %}
{% for item in hostvars[host]['varfoo']['results'] -%}$
{{ item.stdout }},
{%- endfor %}
{% endfor %}


thanks,
Nusenu

Serge van Ginderachter

unread,
Feb 22, 2015, 8:43:07 AM2/22/15
to ansible...@googlegroups.com

On 22 February 2015 at 14:37, Nusenu <nus...@openmailbox.org> wrote:
Is there a way to say loop over all hosts in scope of current task?


Nusenu

unread,
Feb 22, 2015, 8:56:19 AM2/22/15
to ansible...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Serge van Ginderachter:
thanks!
>
(and sorry for missing it when reading the documentation)
-----BEGIN PGP SIGNATURE-----

iQIcBAEBCgAGBQJU6d/iAAoJEFv7XvVCELh0EqQP/1xa0v8ZF+9SDFMqxg0Tdx0v
ti3ftD48TD2zUb3qxJt7/z7plpdnv3R8wXMIYGhgXrT/Zxf1EG9BHx3EnEvnu56y
qTOqSyu32ZlHoisOUGFfhJ59L+V92Fg09fNDzzVEGlcVseUXadDJok+jFgsr5gCV
9ACC9VUqzj/2H9TAmY+s26wJMAfw3CnWFU/EvW/fB2RrVPsbv6l8FxDwMJZPMM/C
GG+POAIFh9eyHvgw1EOiVgEjHwWhNb4Oy5ovCjGnDZxfw9pgNr1/HJmu+jX+NKKJ
rv0o9ztv9n7vPBc1W4RTM4rjmMozc1bgZY1SA7fagaok+Tz2+dNiNGhLaLX8MA5S
A7q+29QMviK/ImyiRVE0cL5ze7FkzIX4C6itqzdCF8dy7BkG1DZkJPNUbeHfE30H
c+BIqnXiAjZgZHg6eUxfx5I5xHTMgW0k5OVErNNcPNigqL7IX1mJ113FOiFz3WaV
w87ZF5JqStkmaHHL5dU11dhcnJwm7TVEljqiohR4wL2C2duDZJ866CDHPTTVL0fP
TG2dGvwN9/STqFed8IvLDT+TTbW2BdUajakgr9lMAw/1yBs0KxYkg1y/RLDZ8rH/
lr9sN2D7eeToTk2vIgFdYiO7VVb6vKz9PSHB3ksjmiZwfyAaiiwEVyan7u3m71Ym
Z2veDPHzYIhglW4NkUBE
=Dy6s
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages