diff --git a/lib/ansible/plugins/connection/ssh.py b/lib/ansible/plugins/connection/ssh.py index 328ace5537..c24a5623ed 100644 --- a/lib/ansible/plugins/connection/ssh.py +++ b/lib/ansible/plugins/connection/ssh.py @@ -591,7 +591,7 @@ class Connection(ConnectionBase): # 0 = success # 1-254 = remote command return code # 255 = failure from the ssh command itself - if return_tuple[0] != 255 or attempt == (remaining_tries - 1): + if return_tuple[0] != 255: break else: raise AnsibleConnectionFailure("Failed to connect to the host via ssh.")