FATAL: all hosts have already failed -- aborting

I am getting

FATAL: all hosts have already failed – aborting

even though none of the hosts are showing any errors. This problem starting creeping up in the 1.5.x releases. Any ideas?

Without more context, it’s impossible to tell what you mean, as this is exactly the message you get after all the hosts have had failures.

Please supply some more context about your playbook run, execution, and so on, and we can discuss further.

This is an interesting side effect of using local tasks vs plays with hosts: 127.0.0.1.

In my case I was running a playbook and on the command line limiting with -l command.

ansible-playbook -l host1 site.yml

in the play book I had the following play:

`
hosts: localhost
user: root
tasks:

  • file: path=“tmp/file1.txt” state=absent
  • file: path=“tmp/file2.txt” state=absent
    `

The plays in the playbook all finished successfully however at the end I got the error listed in the subject of this post: FATAL: all hosts have already failed – aborting.

Looking at the source (lib/ansible/callbacks.py and lib/ansible/playbook/init.py) this error seems to be spit out when (but not only when) the the expected play_count/host_count minus the actual play_count/host_count is greater than the max fail pct (in my case 0).

I figured that having an explicit play with localhost might be confusing the counts. So I changed my code to:

`

  • hosts: dhcp_servers
    user: root
    tasks:
  • local_action: file path=“tmp/file1.txt” state=absent
  • local_action: file path=“tmp/file2.txt” state=absent
    `

The FATAL at the end of the run disappeared. Not sure if it matters but in my inventory file I do have this line:

localhost ansible_ssh_host=127.0.0.1 ansible_connection=local

Something doesn’t seem right here.

It could very well be that the “implicit localhost” magic doesn’t sit well with the failure percentage code – please make sure we have a github ticket on this one with details of how to repro.

Thanks!