mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Catch sshpass authentication errors and don't retry multiple times to prevent account lockout (#50776)
* Catch SSH authentication errors and don't retry multiple times to prevent account lock out Signed-off-by: Sam Doran <sdoran@redhat.com> * Subclass AnsibleAuthenticationFailure from AnsibleConnectionFailure Use comparison rather than range() because it's much more efficient. Signed-off-by: Sam Doran <sdoran@redhat.com> * Add tests Signed-off-by: Sam Doran <sdoran@redhat.com> * Make paramiko_ssh connection plugin behave the same way Signed-off-by: Sam Doran <sdoran@redhat.com> * Add changelog Signed-off-by: Sam Doran <sdoran@redhat.com>
This commit is contained in:
parent
2798d5bafc
commit
9d4c0dc111
5 changed files with 114 additions and 22 deletions
|
@ -141,7 +141,12 @@ from distutils.version import LooseVersion
|
|||
from binascii import hexlify
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
|
||||
from ansible.errors import (
|
||||
AnsibleAuthenticationFailure,
|
||||
AnsibleConnectionFailure,
|
||||
AnsibleError,
|
||||
AnsibleFileNotFound,
|
||||
)
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.six.moves import input
|
||||
from ansible.plugins.connection import ConnectionBase
|
||||
|
@ -355,6 +360,9 @@ class Connection(ConnectionBase):
|
|||
)
|
||||
except paramiko.ssh_exception.BadHostKeyException as e:
|
||||
raise AnsibleConnectionFailure('host key mismatch for %s' % e.hostname)
|
||||
except paramiko.ssh_exception.AuthenticationException as e:
|
||||
msg = 'Invalid/incorrect username/password. {0}'.format(to_text(e))
|
||||
raise AnsibleAuthenticationFailure(msg)
|
||||
except Exception as e:
|
||||
msg = to_text(e)
|
||||
if u"PID check failed" in msg:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue