<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">Bug on current git devel, introduced with <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/eeb597360e6d766bf700e2af4b7b2ae236d55b69/hovercard" href="https://github.com/ansible/ansible/commit/eeb597360e6d766bf700e2af4b7b2ae236d55b69"><tt>eeb5973</tt></a></p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Ubuntu 12.04 and 14.04</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">When applying some filters on a list, when the resulting list is empty, it is not recognised as a list anymore.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
- hosts: localhost
  gather_facts: false
  connection: local
  tasks:
  - command: cat /proc/cpuinfo
    register: cpuinfo
  - debug: var=cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)
  - debug: var=item
    with_items: cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)"><pre class="notranslate"><code class="notranslate">
---
- hosts: localhost
  gather_facts: false
  connection: local
  tasks:
  - command: cat /proc/cpuinfo
    register: cpuinfo
  - debug: var=cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)
  - debug: var=item
    with_items: cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK: [debug var=cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)] ******* 
ok: [localhost] =&gt; {
    &quot;cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)&quot;: &quot;set([])&quot;
}

TASK: [debug var=item] ******************************************************** 
skipping: [localhost]"><pre class="notranslate"><code class="notranslate">TASK: [debug var=cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)] ******* 
ok: [localhost] =&gt; {
    "cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)": "set([])"
}

TASK: [debug var=item] ******************************************************** 
skipping: [localhost]
</code></pre></div>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK: [debug var=cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)] ******* 
ok: [localhost] =&gt; {
    &quot;cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)&quot;: &quot;set([])&quot;
}

TASK: [debug var=item] ******************************************************** 
fatal: [localhost] =&gt; with_items expects a list or a set

FATAL: all hosts have already failed -- aborting"><pre class="notranslate"><code class="notranslate">TASK: [debug var=cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)] ******* 
ok: [localhost] =&gt; {
    "cpuinfo.stdout_lines|difference(cpuinfo.stdout_lines)": "set([])"
}

TASK: [debug var=item] ******************************************************** 
fatal: [localhost] =&gt; with_items expects a list or a set

FATAL: all hosts have already failed -- aborting
</code></pre></div>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.6.6</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">What OS are you running Ansible from and what OS are you managing?  Examples include RHEL 5/6, Centos 5/6, Ubuntu 12.04/13.10, *BSD, Solaris.  If this is a generic feature request or it doesn't apply, just say “N/A”.</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">I have an ansible task that looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: Distribute Jar files to all other cluster nodes
  shell: rsync -avz {{ home }}/.m2 {{ user }}@{{ item }}:{{ home }}/
  with_items: groups.hadoop_all | difference(inventory_hostname)
  when: groups.hadoop_all | difference(inventory_hostname) | length &gt; 1
  ignore_errors: yes
  sudo: no
  tags:
    - distribute_jars"><pre class="notranslate"><code class="notranslate">- name: Distribute Jar files to all other cluster nodes
  shell: rsync -avz {{ home }}/.m2 {{ user }}@{{ item }}:{{ home }}/
  with_items: groups.hadoop_all | difference(inventory_hostname)
  when: groups.hadoop_all | difference(inventory_hostname) | length &gt; 1
  ignore_errors: yes
  sudo: no
  tags:
    - distribute_jars
</code></pre></div>
<p dir="auto">which works fine on ansible 1.6.5 but fails on 1.6.6</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">Working on a reduced test case now.</p>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">I would expect the playbook to complete without errors.</p>
<h5 dir="auto">Actual Results:</h5>
<p dir="auto">The actual result is that it fails in 1.6.6 with this output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK: [dev | Distribute Jar files to all other cluster nodes] *********** 
fatal: [dev] =&gt; with_items expects a list or a set

FATAL: all hosts have already failed -- aborting"><pre class="notranslate"><code class="notranslate">TASK: [dev | Distribute Jar files to all other cluster nodes] *********** 
fatal: [dev] =&gt; with_items expects a list or a set

FATAL: all hosts have already failed -- aborting
</code></pre></div>
<p dir="auto">I've stepped back through ansible versions on a machine, keeping everything else the same and as soon as you upgrade to 1.6.6, it starts falling with this error. I'm using ansible installed via pip, if that makes any difference.</p>