# Throwing "failed" instead of "fatal" when a SSH connection error occurs

**URL:** <https://forum.ansible.com/t/throwing-failed-instead-of-fatal-when-a-ssh-connection-error-occurs/18210>\
**Category:** Ansible Project\
**Created:** [May 12, 2015, 1:44pm UTC](https://forum.ansible.com/t/throwing-failed-instead-of-fatal-when-a-ssh-connection-error-occurs/18210 "2015-05-12T13:44:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pascal\_Mathis](https://avatars.discourse-cdn.com/v4/letter/p/43a26b/32.png) [@Pascal\_Mathis](https://forum.ansible.com/u/Pascal_Mathis)\
**Post date:** [May 12, 2015, 1:44pm UTC](https://forum.ansible.com/t/throwing-failed-instead-of-fatal-when-a-ssh-connection-error-occurs/18210/1 "2015-05-12T13:44:58Z")

</div>

Today I’ve needed an Ansible play which first tries to connect with A (e.g. port 22, user hello) and if that should fail, fall back to B (e.g. port 22, user world). I’ve started scripting and it all looked great until I’ve ran into a big problem: Whenever a SSH connection fails, Ansible throws a “fatal” instead of just an usual “failed”, so “ignore\_errors” does not help at all.

I now came up with my own solution, which involves a callback module: Whenever the environment variable **soft\_connection\_errors** is set within a task, SSH connections will fail and no longer throw any fatal errors. I’ve uploaded my code as a Gist: [Ansible Connection Bootstrapper](https://gist.github.com/NeoXiD/269618ba001b51abb0d2)

Is there any better solution available? Runtime method patching just doesn’t seem right to me, even if it perfectly works.
