Is it possible to have Ansible retry on connection failure?

Petr picture Petr · Oct 31, 2016 · Viewed 13.1k times · Source

I am facing this annoying bug: Ansible hosts are randomly unreachable #18188 .

Is there a way to tell Ansible that if SSH connection fails, to try it once more? Or 2 times more?

According this post New SSH Retry In Ansible 2.0? there is "retries" option but it doesn't seem very trustworthy to me, the person who posted didn't even get SSH header right and there is no mention of this in Ansible docs.

Answer

techraf picture techraf · Oct 31, 2016

Yes, it is possible using the method which you referenced in your question, i.e. by placing the following parameter in ansible.cfg:

[ssh_connection]
retries=2