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

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

​The special variable​ 'play_hosts' is what you are looking for.

http://docs.ansible.com/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts

Serge van Ginderachter:

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

​The special variable​ 'play_hosts' is what you are looking for.

http://docs.ansible.com/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts

thanks!

(and sorry for missing it when reading the documentation)