Fix hang on unkown host key for network_cli (#32937)
* Don't prompt on force_persistent either * Propagate persistence setting to lower paramiko connection
This commit is contained in:
parent
1a2eb319fe
commit
37d8242e44
2 changed files with 3 additions and 4 deletions
|
@ -78,7 +78,6 @@ class Connection(ConnectionBase):
|
|||
def __init__(self, play_context, new_stdin, *args, **kwargs):
|
||||
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
|
||||
|
||||
self.ssh = None
|
||||
self._ssh_shell = None
|
||||
|
||||
self._matched_prompt = None
|
||||
|
@ -164,12 +163,12 @@ class Connection(ConnectionBase):
|
|||
|
||||
p = connection_loader.get('paramiko', self._play_context, '/dev/null')
|
||||
p.set_options(direct={'look_for_keys': bool(self._play_context.password and not self._play_context.private_key_file)})
|
||||
p.force_persistence = self.force_persistence
|
||||
ssh = p._connect()
|
||||
self.ssh = ssh.ssh
|
||||
|
||||
display.vvvv('ssh connection done, setting terminal', host=self._play_context.remote_addr)
|
||||
|
||||
self._ssh_shell = self.ssh.invoke_shell()
|
||||
self._ssh_shell = ssh.ssh.invoke_shell()
|
||||
self._ssh_shell.settimeout(self._play_context.timeout)
|
||||
|
||||
network_os = self._play_context.network_os
|
||||
|
|
|
@ -188,7 +188,7 @@ class MyAddPolicy(object):
|
|||
fingerprint = hexlify(key.get_fingerprint())
|
||||
ktype = key.get_name()
|
||||
|
||||
if C.USE_PERSISTENT_CONNECTIONS:
|
||||
if C.USE_PERSISTENT_CONNECTIONS or self.connection.force_persistence:
|
||||
# don't print the prompt string since the user cannot respond
|
||||
# to the question anyway
|
||||
raise AnsibleError(AUTHENTICITY_MSG[1:92] % (hostname, ktype, fingerprint))
|
||||
|
|
Loading…
Reference in a new issue