<h5 dir="auto">Issue Type: Bug Report</h5>
<h5 dir="auto">Ansible Version: ansible-playbook 1.5</h5>
<h5 dir="auto">Environment: OSX, Debian Squeeze</h5>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Imagine a playbook, with a play that has a hosts: line of localhost</p>
<p dir="auto">Imagine running this playbook, with a --limit derp, which does not include localhost.</p>
<p dir="auto">You'd expect this to skip the play with no matching hosts, but instead the play will get executed, and then the playbook will immediately fail with FATAL: all hosts have already failed.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">test.yaml</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
- name: Test play 1
  hosts: localhost
  gather_facts: no

  tasks:
    - name: derp
      debug: msg=&quot;herp&quot;"><pre class="notranslate"><code class="notranslate">
---
- name: Test play 1
  hosts: localhost
  gather_facts: no

  tasks:
    - name: derp
      debug: msg="herp"
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook -i derp, test.yaml -vv --limit derp"><pre class="notranslate"><code class="notranslate">$ ansible-playbook -i derp, test.yaml -vv --limit derp
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [Test play 1] ************************************************************
skipping: no hosts matched"><pre class="notranslate"><code class="notranslate">PLAY [Test play 1] ************************************************************
skipping: no hosts matched
</code></pre></div>
<p dir="auto">or</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK: [derp] ******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;herp&quot;
}"><pre class="notranslate"><code class="notranslate">TASK: [derp] ******************************************************************
ok: [localhost] =&gt; {
    "msg": "herp"
}
</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: [derp] ******************************************************************
ok: [localhost] =&gt; {
    &quot;msg&quot;: &quot;herp&quot;
}

FATAL: all hosts have already failed -- aborting"><pre class="notranslate"><code class="notranslate">TASK: [derp] ******************************************************************
ok: [localhost] =&gt; {
    "msg": "herp"
}

FATAL: all hosts have already failed -- aborting
</code></pre></div>
<p dir="auto">Through some bisecting, I think the offending commit is<br>
<a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/ae9843fccdac1bc5da95f2c9d274e927f4a43962/hovercard" href="https://github.com/ansible/ansible/commit/ae9843fccdac1bc5da95f2c9d274e927f4a43962"><tt>ae9843f</tt></a><br>
but I'm not positive. I believe it's a combination of this commit, along with the introduction of the implicit localhost inventory entry. More testing to continue, but I wanted to get this filed for tracking.</p>
<p dir="auto">Including "disablerepo=*" appears to disable all repos, including those explicitly enabled with enablerepo.</p>
<p dir="auto">From within the vm, the following installs the package as expected:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="sudo yum install yum-plugin-downloadonly --disablerepo=* --enablerepo=mylocalrepo"><pre class="notranslate"><code class="notranslate">sudo yum install yum-plugin-downloadonly --disablerepo=* --enablerepo=mylocalrepo
</code></pre></div>
<p dir="auto">However, with the following playbook entry, the package cannot be found:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- name: installing yum-plugin-downloadonly
  action: yum name=yum-plugin-downloadonly
          disablerepo=*
          enablerepo=mylocalrepo
          state=present
  tags: yum-config
  sudo: yes

TASK: [common | installing yum-plugin-downloadonly] *************************** 
failed: [10.10.10.100] =&gt; {&quot;changed&quot;: false, &quot;failed&quot;: true, &quot;item&quot;: &quot;&quot;, &quot;rc&quot;: 0, &quot;results&quot;: []}
msg: No Package matching 'yum-plugin-downloadonly' found available, installed or updated

FATAL: all hosts have already failed -- aborting"><pre class="notranslate"><code class="notranslate">- name: installing yum-plugin-downloadonly
  action: yum name=yum-plugin-downloadonly
          disablerepo=*
          enablerepo=mylocalrepo
          state=present
  tags: yum-config
  sudo: yes

TASK: [common | installing yum-plugin-downloadonly] *************************** 
failed: [10.10.10.100] =&gt; {"changed": false, "failed": true, "item": "", "rc": 0, "results": []}
msg: No Package matching 'yum-plugin-downloadonly' found available, installed or updated

FATAL: all hosts have already failed -- aborting
</code></pre></div>