title: Jinja syntax for YAML File
body: <p>I've been reading a lot about loops in python and JINJA but I've not found the right answer for my problem. I'm really new to programming so I must be missing something</p>
  
  <p>I'hve got the following <strong>YAML file</strong></p>
  
  <pre><code>CONT_PLANE_PROT_V4:
    - RANGES:
      - 10.193.130.240/28
      - 10.193.135.240/28
    - HOSTS:
      - 10.193.131.131
      - 10.196.180.5
  </code></pre>
  
  <p>I'd like to generate a template with those variables and if I print the variable in Ansible it shows like this:</p>
  
  <p><strong>Printing Variable</strong></p>
  
  <pre><code>[{u'RANGES': [u'10.193.130.240/28', u'10.193.135.240/28']}, {u'HOSTS': [u'10.193.131.131', u'10.196.180.5']}]
  </code></pre>
  
  <p>I'm trying the following in the JINJA template with no success:</p>
  
  <p><strong>JINJA TEMPLATE</strong></p>
  
  <pre><code>{% for list in CONT_PLANE_PROT_V4 %}
    {% for ips in CONT_PLANE_PROT_V4[list] %}      
  
      Statement1 {{RANGES_IPs}
  
    {% endfor %}
  {% endfor %}
  
  {% for list in CONT_PLANE_PROT_V4 %}
    {% for ips in CONT_PLANE_PROT_V4[list] %}  
  
      Statement2 {{HOSTS_IPs}}
  
    {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p><strong>Ansible Error:</strong> <code>"AnsibleUndefinedVariable: list object has no element {u'RANGES': [u'10.193.130.240/28', u'10.193.135.240/28', u'10.183.64.240/28', u'10.183.60.240/28', u'10.183.106.240/28', u'10.36.12.240/28', u'10.128.64.240/28', u'10.44.12.240/28', u'10.213.12.240/28', u'10.111.64.240/28', u'10.193.80.240/28']}"}</code></p>
  
  <p><strong>Request:</strong>
  Can you please let me know the best way or the easiest way to properly get the value of the 2 lists (4 IPs). I will need to access the values on the "RANGES" and the "HOST" lists. The values on the "RANGES" List will be used on statement 1 and the values on the "HOSTS" list will be used on statement 2.</p>
  
  <p>Something like this:</p>
  
  <p><strong>Expected result</strong></p>
  
  <pre><code>statement1 10.193.130.240/28
  statement1 10.193.135.240/28
  
  statement2 10.193.131.131
  statement2 10.196.180.5
  </code></pre>