title: ansible using loop and multiple variables
body: <p>i am using "<strong>shell:</strong>" to get some data by looping over "<strong>with_items:</strong>" and registering it as another variable.
  Later using "<strong>lineinfile:</strong>" i am trying to apply the contents of earlier variable,but  not able to use "<strong>{{variable.stdout}}</strong>" as it is showing as undefined in "<strong>with_items:</strong>"</p>
  
  <p>Is there a way to tell ansible that for "<strong>variable.stdout</strong>" don't look in "<strong>with_items:</strong>"</p>
  
  <pre><code>---
  - include_vars: /root/template.yml
  
  - name: Getting MAC
    shell: "cat /sys/class/net/{{item.name}}/address"
    register: mac
    with_items:
    - "{{ interfaces_ipv4 }}"
  
  - name: Setting MAC
     lineinfile:
     state=present
     dest=/etc/sysconfig/network-scripts/ifcfg-{{item.name}}
     regexp='^HWADDR=.*'
     line="HWADDR={{mac.stdout}}"
    with_items:
     - "{{ interfaces_ipv4 }}"
    tags:
     - set_mac
  </code></pre>
  
  <p>Contents of variable file</p>
  
  <pre><code>#/root/tempplate.yml
  
  - name: ens35
    bootproto: dhcp
  - name: ens34
    bootproto: none
  </code></pre>
  
  <p>When executing:</p>
  
  <p>TASK: [mac | Setting MAC] *****************************************************
  fatal: [192.168.211.146] => <strong>One or more undefined variables: 'dict' object has no attribute 'stdout'</strong></p>
  
  <p>FATAL: all hosts have already failed -- aborting</p>