title: Creating list of ip's in ansible using given range within jinja template
body: <p>i want to generate a list of ip addresses (using range of last 8bits so 120-190 translates to x.x.x.120 - x.x.x.190) in defaults/main.yml in my role, and later use it to create new network interfaces and generate a new config file. I tried this approach: </p>
  
  <p><strong>defaults/main.yml:</strong></p>
  
  <p><code>ip_list: "{%for address_end in range(50,99)%} 192.168.0.{{address_end}}{%endfor%}"
  conf_list: "{%for ip in ip_list%}server {{ip}}:6666 {%endfor%}"</code></p>
  
  <p>and then to use it in template</p>
  
  <p><strong>template.conf.j2:</strong></p>
  
  <pre><code>{% for conf_line in conf_list %}
  {{conf_line}}
  {% endfor %}
  </code></pre>
  
  <p>and all i got in generated config file was:</p>
  
  <pre><code>            s
              e
              r
              v
              e
              r
  
  
              :
              6
              6
              6
              6
  
              s
              e
              r
              v
              e
              r
  
              1
              :
              6
  </code></pre>
  
  <p>so my guess is that i'm not generating a list but just a long string and when I use for loop in <strong>template.conf.j2</strong> I iterate over single chars. I tried using answer to <a href="https://stackoverflow.com/questions/29704728/how-to-create-dynamic-list-in-yaml">this</a> problem but all i got was syntax error. Any ideas for what might help me ?</p>