title: Unable to create conf file using Jinja - Expected Variables for Nginx
body: <p>I am learning to use Jinja today to template a config file that I manually created and tested for Nginx. So far the template works as expected and it pulls the dynamic variables as expected. However, I have one line in my conf that needs to be on two separate lines and for some reason, it puts the two host on the same line. </p>
  
  <p>This seems really simple, but I can't seem to spot what is causing it. I've gotten this far so! </p>
  
  <p>My nginx.yml file</p>
  
  <pre><code>---
  test_url: abc.{{ nginx_domain }}
  nginx_ssl_port: 443
  nginx_proxy_conf_dir: /etc/some/place
  nginx_ssl_key_dir:  /etc/somekey/place
  nginx_ssl_cert_dir: /etc/somecert/place
  nginx_proxy_log_dir: /etc/some/proxy/place
  ##Env depends on ansible inventory
  
  test_nginx_proxy_sites:
  - name: test
    params:
    - 'listen {{ nginx_ssl_port }} ssl'
    - 'server_name {{test_url}}'
    - 'include {{ nginx_proxy_conf_dir }}/conf.d/ssl.conf'
    - 'ssl_certificate {{ nginx_ssl_cert_dir }}/{{ nginx_domain }}.crt'
    - 'ssl_certificate_key {{ nginx_ssl_key_dir }}/{{ nginx_domain }}.key'
    - 'access_log {{ nginx_proxy_log_dir }}/management_access.log'
    - 'error_log {{ nginx_proxy_log_dir }}/management_error.log'
    locations:
    - path: /
      location_params:
      - 'proxy_pass http://stream_{{ Env }}/'
      - 'include {{ nginx_proxy_conf_dir }}/conf.d/proxy.conf'
    upstreams:
    - name: stream_{{ Env }}
      params:
      - '{% for host in groups.tag_Class_host %}
      server {{ hostvars[host].ipv4_local }}:{{ management_port }};
      {% endfor %}
      '
  </code></pre>
  
  <p>My sites.conf.j2</p>
  
  <pre><code>{{ remotely_managed }}
  server {
  {% if item.blocks is defined and item.blocks|length &gt; 0 %}
  {% for block in item.blocks %}
    {{ block }}
  {% endfor %}
  {% endif %}
  {% for param in item.params %}
    {{ param }};
  {% endfor %}
  {% if item.locations is defined and item.locations|length &gt; 0 %}
  
  {% for location in item.locations %}
    location {% if location.match is defined %}{{ location.match }} {% endif %}{{ location.path }} {
  {% if location.root is defined %}
      root {{ location.root }};
  {% endif %}
  {% if location.location_params is defined and location.location_params|length &gt; 0 %}
  {% for param in location.location_params %}
      {{ param }};
  {% endfor %}
  {% endif %}
    }
  {% endfor %}
  {% endif %}
  {% if item.errors is defined and item.errors|length &gt; 0 %}
  {% for error in item.errors %}
    {{ error.directive }};
    location {{ error.location }} {
  {% for param in error.error_params %}
      {{ param }};
  {% endfor %}
    }
  {% endfor %}
  {% endif %}
  }
  {% if item.upstreams is defined %}
  {% for u in item.upstreams %}
  upstream {{ u.name }} {
  {% if u.params is defined %}
  {% for param in u.params %}
  {{ param }}
  {% endfor %}
  {% endif %}
  }
  {% endfor %}
  {% endif %}
  </code></pre>
  
  <p>My output</p>
  
  <pre><code>server {
    server_name abc.mytest.com;
    include /etc/nginx/conf.d/ssl.conf;
    ssl_certificate /etc/somecert/place/certs/abc.mytest.com.crt;
    ssl_certificate_key /etc/somekey/place/private/abc.mytest.com.key;
    access_log /var/log/nginx/management_access.log;
    error_log /var/log/nginx/management_error.log;
  
    location / {
      proxy_pass http://stream_qa/;
      include /etc/nginx/conf.d/proxy.conf;
    }
  }
  upstream stream_qa {
   server 1.1.1.09:11111;    server 1.1.1.10:11111;
    }
  </code></pre>
  
  <p>The upstream should print out like below:</p>
  
  <pre><code>upstream stream_qa {
   server 1.1.1.09:11111;
   server 1.1.1.10:11111;
    }
  </code></pre>