title: Looping over list data in Ansible playbooks
body: <p>In my quest to automate some of our network environment I would like to know how you could loop over different items in nested lists. To make it more clear I will explain what I want to do using my existing inventory and playbook.</p>
  
  <p>Inventory looks as followed, (Dummy Content)</p>
  
  <pre><code>parameters:
  - mode: ""
    speed: ""
    duplex: ""
  interfaces:
    - Int_One
    - Int_Two
  </code></pre>
  
  <p>So as you can see I have a list containing some network information (parameters) and another list containing two interfaces. The action that I want to accomplish in my playbook is to configure those two interfaces with the information found in the "parameters" list. In other words, loop over the "interfaces" using the information in the "parameters" list. But as of right now I can't get it to use the right data in the right time</p>
  
  <p>Good to know is that I'm using a predefined "Cisco network module" in my playbook. </p>
  
  <p>Playbook looks as followed,</p>
  
  <pre><code>- name: Deploy Network Interfaces
    "Some network module":
      mode: '{{ item.0.mode }}'
      speed: '{{ item.0.speed }}'
      duplex: '{{ item.0.duplex }}'
      interface: '{{ item.1.interfaces }}'
      state: present
    delegate_to: localhost
    loop: 
      - "{{ parameters }}"
      - "{{ parameters|subelements('interfaces') }}"
  </code></pre>
  
  <p>As you can see the network module requires the "interface" to be provided. So again I want to iterate over the "interfaces" list and deploy them with the defined data in the "parameters" list. </p>
  
  <p>Anyone that can tell me how to handle this issue?</p>
  
  <p>Thanks in advance!</p>