title: ansible template add value to list -
body: <p>based on the following ansible playbook values ..</p>
  
  <pre><code>target:  "actual.domain.com"
  aliases:
    - "alias1.domain.com"
    - "alias2.domain.com"
  </code></pre>
  
  <p>I am trying to setup an ansible template to produce the nginx server_name
  which in this case should be:</p>
  
  <pre><code>server_name: "actual.domain.com alias1.domain.com alias2.domain.com"
  </code></pre>
  
  <p>so , I tried the following jinja2 script ...</p>
  
  <pre><code>{% if item.aliases is defined %}
      {% set servername = [ item.target ] %}
      {% for alias in item.aliases.iteritems() %}
         {% if alias|length &gt; 0 %}
             {% servername|join(' '), alias %}  # &lt;= line 30
         {% endif %}
      {% endfor %}
      server_name {{ servername }};
   {% else %}
       server_name {{ item.target }};
   {% endif %}
    ....
  </code></pre>
  
  <p>but it's failing ,  line number: 30, error: Encountered unknown tag 'servername'</p>
  
  <p>where could I be wrong ?</p>
  
  <p>thanks for help and HNY !</p>