Ansible - FATAL: all hosts have already failed

When restarting a service with Ansible and Vagrant just won't work because 'All hosts have already failed'

Posted by Thomas Barthelemy on May 25, 2015

I finally had a little time to “fix” a bug that recently shown up:

When trying to restart a service during a vagrant provisioning with Ansible on a Windows host, I was given the following error:

==> default: NOTIFIED: [php | restart PHP-FPM] *********************************
************
==> default: failed: [default] => {"failed": true}
==> default:
==> default: FATAL: all hosts have already failed -- aborting

Some service would restart correctly while some other just won’t work, and restarting the service manually would work just fine.

After a quick investigation it seems to be more of a Vagrant issue than anything else so a quick fix would be to replace:

- name: restart PHP-FPM
service: name=php5-fpm state=restarted

By:

- name: restart PHP-FPM
command: service php5-fpm restart

Posted with : Vagrant , Linux , Ansible

blog comments powered by Disqus