title: Extra spaces appearing in Ansible templates
body: <p>I am generating config files and I want them to be indented just so. I started with a Jinja2 template that rendered correctly when called from a simple python program. When I call it from ansible, I will get 2 extra spaces on all but the first line of the loop. Generating things like YAML and python has been a real pain. I have taken to putting a comment line as the first line of a for block to fix this...</p>
  
  <p>Here is a really simple example of a YAML generator:</p>
  
  <p>playbook call:</p>
  
  <pre><code>  - name: generate bgp vars file, put in includes directory
      local_action: template src={{ role_dir }}/templates/bgp_vars.j2 dest={{ incvar_dir }}/bgp_vars.yaml
      run_once: true
  </code></pre>
  
  <p>section of template:</p>
  
  <pre><code>dc_route_reflectors:
  {% for dc in SH_dcs %}
  # dc is "{{ dc }}"
    {{ dc }}:
    {% for host in groups[bgpgroupname] if dc == hostvars[host].MYDC %}
      - "{{ hostvars[host].MAIN_MYADDR }}"
    {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>rendered output:</p>
  
  <pre><code>dc_route_reflectors:
  
  # dc is "pnp"
    pnp:
        - "10.100.16.3"
        - "10.100.32.3"
    # dc is "sgs"
    sgs:
        - "10.8.0.3"
        - "10.8.16.3"
    # dc is "cst"
    cst:
        - "10.4.0.3"
        - "10.4.16.3"
    # dc is "dse"
    dse:
        - "10.200.0.3"
        - "10.200.16.3"
  </code></pre>
  
  <p>Notice how the dc is "pnp" comment is not indented as it is shown in the template, but sgs,cst and dse comments are indented by 2 spaces. All of the array lines of ip addresses are also indented. I have tried various versions of adding "-" to the "%" things as Jinja2 describes, but none have given consistent correct results.</p>
  
  <p>Others must have seen this before. I'm running 2.2.1.0 on CentOS7.</p>