Iterate over a array in with_items loop
<p>Based on this question</p>

<p><a href="https://stackoverflow.com/questions/39254122/ansible-recursive-checks-in-playbooks">Ansible recursive checks in playbooks</a></p>

<p>I have another one.</p>

<p>We need to go through this structure</p>

<p>Zone spec <a href="https://gist.github.com/git001/9230f041aaa34d22ec82eb17d444550c" rel="nofollow noreferrer">https://gist.github.com/git001/9230f041aaa34d22ec82eb17d444550c</a></p>

<p>Now I can adress the hostnames via the array index but can I also iterate over the array "<strong>hosts</strong>"?</p>

<p>playbook</p>

<pre><code>--
- hosts: all
  gather_facts: no

  vars_files:
    - "../doc/application-zone-spec.yml"

  roles:
    - { role: ingress_add, customers: "{{ application_zone_spec }}" }
</code></pre>

<p>role</p>

<pre><code> - name: Print ingress hostnames
   debug: msg="{{ item.hosts.0.hostname }} {{ item.hosts.1.hostname }}"
   with_items: "{{ customers.ingress }}"
</code></pre>

<p>We use.</p>

<pre><code>ansible-playbook --version
ansible-playbook 2.1.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre>