title: Ansible jinja dictionary create multiple files
body: <p>I want to create multiple in ansible loop with jinja template, like that :</p>
  <p>template_a</p>
  <pre><code>name = a
  username = c
  </code></pre>
  <p>template_b</p>
  <pre><code>name = b
  username = d
  </code></pre>
  <p>playbook.yml</p>
  <pre><code>- name: Create file from jinja
    template:
      src: &quot;jinja.j2&quot;
      dest: &quot;template_{{ item }}&quot;
      owner: &quot;root&quot;
      group: &quot;root&quot;
    with_items: &quot;{{ jinja_var }}&quot;
  </code></pre>
  <p>variables.yml</p>
  <pre><code>jinja_var:
    a: c
    b: d
  </code></pre>
  <p>jinja.j2</p>
  <pre><code>{% for (key,value) in jinja_var.iteritems() %}
  name =  {{ key }}
  username =  {{ value }}
  {% endfor %}
  </code></pre>
  <p>I have got two same files :</p>
  <pre><code>name =  a
  username =  1
  name =  b
  username =  2
  </code></pre>