title: Ansible AnsibleUndefinedVariable no attribute
body: <p>I have the following files vars/main.yml</p>
  
  <pre><code>testconfig:
   - {hostname: router123, example: no ip cef}
  
  cisco_891_l2interfaces:
   - FastEthernet0
   - FastEthernet1
   - FastEthernet2
   - FastEthernet3
   - FastEthernet4
   - FastEthernet5
   - FastEthernet6
   - FastEthernet7
  
  euvar:
   - {dc1: "1.1.1.1", dc2: "1.2.2.2"}
  </code></pre>
  
  <p>tasks main.yml</p>
  
  <pre><code>- name: Generate configuration files for DMVPN router
    template: src=router.j2 dest=/lib/python2.7/site-packages/ansible/RTR-TEMPLATE/bla/bla.txt
    with_items: testconfig
  </code></pre>
  
  <p>router.j2</p>
  
  <pre><code>{{item.example}}
  
  !
  boot-start-marker
  boot-end-marker
  !
  
  {{euvar.dc1}}
  </code></pre>
  
  <p>This gives me the error, I am unsure how to reference euvar.dc1 from router.j2</p>
  
  <pre><code>    TASK: [router | Generate configuration files for DMVPN router] ****************
  fatal: [localhost] =&gt; {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'list object' has no attribute 'dc1'", 'failed': True}
  fatal: [localhost] =&gt; {'msg': 'One or more items failed.', 'failed': True, 'changed': False, 'results': [{'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'list object' has no attribute 'dc1'", 'failed': True}]}
  
  FATAL: all hosts have already failed -- aborting
  </code></pre>