<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">v1.6.7+, devel</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Debian, Ubuntu</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Recent <a href="https://github.com/ansible/ansible/commit/62a1295a3e08cb6c3e9f1b2a1e6e5dcaeab32527">security fix</a> prevents me from using Jinja2 <code class="notranslate">{% if %}{% else %}{% endif %}</code> syntax in a task. This prevents me from creating more flexible roles that can be easily customized using inventory lists. Basically 80% of my playbook is based around this... :-(</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
# An example play which lets you customize the directory names using variables from inventory
- hosts: all
  vars:
    dir_list:
      - name: 'directory'
        prefix: 'my_'
      - name: 'other_directory'
  tasks:
    - name: Create example directories
      file: state=directory
            {% if item.prefix is defined and item.prefix %}
            dest=/tmp/{{ item.prefix + item.name }}
            {% else %}
            dest=/tmp/{{ item.name }}
            {% endif %}
      with_items: dir_list"><pre class="notranslate"><code class="notranslate">
---
# An example play which lets you customize the directory names using variables from inventory
- hosts: all
  vars:
    dir_list:
      - name: 'directory'
        prefix: 'my_'
      - name: 'other_directory'
  tasks:
    - name: Create example directories
      file: state=directory
            {% if item.prefix is defined and item.prefix %}
            dest=/tmp/{{ item.prefix + item.name }}
            {% else %}
            dest=/tmp/{{ item.name }}
            {% endif %}
      with_items: dir_list
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Two directories are created, <code class="notranslate">/tmp/my_directory/</code> and <code class="notranslate">/tmp/other_directory/</code>.</p>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [all] ******************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [winterfell]

TASK: [Create example directories] ******************************************** 
fatal: [winterfell] =&gt; a duplicate parameter was found in the argument string (dest)

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/drybjed/test_dest.retry

winterfell                 : ok=1    changed=0    unreachable=1    failed=0   "><pre class="notranslate"><code class="notranslate">PLAY [all] ******************************************************************** 

GATHERING FACTS *************************************************************** 
ok: [winterfell]

TASK: [Create example directories] ******************************************** 
fatal: [winterfell] =&gt; a duplicate parameter was found in the argument string (dest)

FATAL: all hosts have already failed -- aborting

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/drybjed/test_dest.retry

winterfell                 : ok=1    changed=0    unreachable=1    failed=0   
</code></pre></div>
<p dir="auto">Hi! Let's have a playbook like these:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- hosts: all
  sudo: yes
  tasks:
    - name: Reproduce items bug
      yum: name=nagios-plugins-{{ item }} state=present
      with_items:
        - dhcp
        - disc
        - dummy"><pre class="notranslate">- <span class="pl-ent">hosts</span>: <span class="pl-s">all</span>
  <span class="pl-ent">sudo</span>: <span class="pl-s">yes</span>
  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">name</span>: <span class="pl-s">Reproduce items bug</span>
      <span class="pl-ent">yum</span>: <span class="pl-s">name=nagios-plugins-{{ item }} state=present</span>
      <span class="pl-ent">with_items</span>:
        - <span class="pl-s">dhcp</span>
        - <span class="pl-s">disc</span>
        - <span class="pl-s">dummy</span></pre></div>
<p dir="auto">and if you run this playbook, you can see an error:</p>
<blockquote>
<p dir="auto">failed: [mylovelyhost] =&gt; (item=dhcp,disc,dummy) =&gt; {"changed": false, "failed": true, "item":  "dhcp,disc,dummy", "rc": 0, "results": ["nagios-plugins-dhcp-1.4.16-10.fc20.x86_64 providing nagios-plugins-dhcp is already installed"]}<br>
msg: No Package matching 'disc' found available, installed or updated</p>
</blockquote>
<p dir="auto">So, string concatenation with {{ item }} variable in with_items cycle will only work for the first step. For next steps only pure {{ item }} will sended.</p>