<p dir="auto"><strong>Ansible Version</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.0.0 (devel da4b4a2a33) last updated 2015/11/09 08:53:14 (GMT +300)
  lib/ansible/modules/core: (detached HEAD 750aa16a06) last updated 2015/11/09 08:53:39 (GMT +300)
  lib/ansible/modules/extras: (detached HEAD 62f52d702a) last updated 2015/11/09 08:53:39 (GMT +300)"><pre class="notranslate"><code class="notranslate">ansible 2.0.0 (devel da4b4a2a33) last updated 2015/11/09 08:53:14 (GMT +300)
  lib/ansible/modules/core: (detached HEAD 750aa16a06) last updated 2015/11/09 08:53:39 (GMT +300)
  lib/ansible/modules/extras: (detached HEAD 62f52d702a) last updated 2015/11/09 08:53:39 (GMT +300)
</code></pre></div>
<p dir="auto"><strong>Summary</strong></p>
<p dir="auto">Given a task like this:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    - apt: name=&quot;{{ item }}&quot; state=present
      with_items: &quot;{{ packages }}&quot;"><pre class="notranslate">    - <span class="pl-ent">apt</span>: <span class="pl-s">name="{{ item }}" state=present</span>
      <span class="pl-ent">with_items</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ packages }}<span class="pl-pds">"</span></span></pre></div>
<p dir="auto">Ansible v1 processes it correctly, but ansible v2 installs the 1st package N times.</p>
<p dir="auto"><strong>Steps to Reproduce</strong></p>
<ul dir="auto">
<li>create a <code class="notranslate">test.yml</code>:</li>
</ul>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
---
- hosts: localhost
  gather_facts: no
  vars:
    packages:
      - build-essential
      - python-dev
      - python-virtualenv
      - gettext
  tasks:
    - apt: name=&quot;{{ item }}&quot; state=present
      with_items: &quot;{{ packages }}&quot;"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">localhost</span>
  <span class="pl-ent">gather_facts</span>: <span class="pl-s">no</span>
  <span class="pl-ent">vars</span>:
    <span class="pl-ent">packages</span>:
      - <span class="pl-s">build-essential</span>
      - <span class="pl-s">python-dev</span>
      - <span class="pl-s">python-virtualenv</span>
      - <span class="pl-s">gettext</span>
  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">apt</span>: <span class="pl-s">name="{{ item }}" state=present</span>
      <span class="pl-ent">with_items</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ packages }}<span class="pl-pds">"</span></span></pre></div>
<ul dir="auto">
<li>run <code class="notranslate">ansible-playbook test.yml -C</code></li>
</ul>
<p dir="auto"><strong>Expected Behavior</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [localhost] ************************************************************** 

TASK: [apt name=&quot;{{ item }}&quot; state=present] *********************************** 
ok: [localhost] =&gt; (item=build-essential,python-dev,python-virtualenv,gettext)

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

TASK: [apt name="{{ item }}" state=present] *********************************** 
ok: [localhost] =&gt; (item=build-essential,python-dev,python-virtualenv,gettext)

PLAY RECAP ******************************************************************** 
localhost                  : ok=1    changed=0    unreachable=0    failed=0   
</code></pre></div>
<p dir="auto"><strong>Actual Behavior</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY ***************************************************************************

TASK [apt state=present name={{ item }}] ***************************************
ok: [localhost] =&gt; (item=[u'build-essential', u'build-essential', u'build-essential', u'build-essential'])

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0   "><pre class="notranslate"><code class="notranslate">PLAY ***************************************************************************

TASK [apt state=present name={{ item }}] ***************************************
ok: [localhost] =&gt; (item=[u'build-essential', u'build-essential', u'build-essential', u'build-essential'])

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0   
</code></pre></div>
<p dir="auto"><strong>Other Comments</strong></p>
<p dir="auto">The bug goes away if I use a different module (such as <code class="notranslate">command: echo {{ item }}</code>) instead of <code class="notranslate">apt</code>.</p>
<p dir="auto">Issue Type:</p>
<p dir="auto">Bug Report</p>
<p dir="auto">Ansible Version:</p>
<p dir="auto"><em>this was the commit that broke it</em><br>
ansible checkout <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/5040abaaf24a3de32ac665a35e83a5348de43098/hovercard" href="https://github.com/ansible/ansible/commit/5040abaaf24a3de32ac665a35e83a5348de43098"><tt>5040aba</tt></a></p>
<p dir="auto">Ansible Configuration:</p>
<p dir="auto">N/A</p>
<p dir="auto">Environment:</p>
<p dir="auto">Centos 6.7</p>
<p dir="auto">Summary:</p>
<p dir="auto">Steps To Reproduce:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="yum: name={{ item }} state=installed
with_items: yum_pkgs"><pre class="notranslate"><code class="notranslate">yum: name={{ item }} state=installed
with_items: yum_pkgs
</code></pre></div>
<p dir="auto">it just lists the the first item in yum_pkgs as every item so if for example</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="yum_pkgs:
 - vim
 - gedit"><pre class="notranslate"><code class="notranslate">yum_pkgs:
 - vim
 - gedit
</code></pre></div>
<p dir="auto">Expected Results:</p>
<p dir="auto">It installs vim and gedit</p>
<p dir="auto">Actual Results:</p>
<p dir="auto">It would install vim and vim</p>
<p dir="auto">it would act like the list was</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="yum_pkgs:
 - vim
 - vim"><pre class="notranslate"><code class="notranslate">yum_pkgs:
 - vim
 - vim
</code></pre></div>
<p dir="auto">same thing for</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="yum: name={{ item }} state=installed
with_items: &quot;{{ yum_pkgs }}&quot;"><pre class="notranslate"><code class="notranslate">yum: name={{ item }} state=installed
with_items: "{{ yum_pkgs }}"
</code></pre></div>
<p dir="auto">and</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="yum: name={{ item}} state=installed
with_items: 
- &quot;{{ yum_pkgs }}&quot;"><pre class="notranslate"><code class="notranslate">yum: name={{ item}} state=installed
with_items: 
- "{{ yum_pkgs }}"
</code></pre></div>