title: Ansible nested loops through inventories
body: <p>I was looking at the Loops page of Ansible <a href="https://docs.ansible.com/ansible/2.7/user_guide/playbooks_loops.html" rel="nofollow noreferrer">https://docs.ansible.com/ansible/2.7/user_guide/playbooks_loops.html</a> but I could not find what I am looking for...</p>
  
  <p>I would like to test if a "source" host can reach / connect to a set of target hosts on a set of ports. Each set of target host can be, for example, an inventory group and each inventory group has a list of their own ports to be tested.</p>
  
  <p>The idea is to specify only two vars as input to the playbook: a list of groups of hosts and a list of one or more source hosts.</p>
  
  <p>How the loop should be done? The inventory can be YAML or INI files: one or multiple, for each group. The test of a TCP connection is easy... so the focus is only on the input vars and loop construction.</p>
  
  <p>Thanks and regards.</p>
  
  <p>Stef</p>