Fix hang on unkown host key for network_cli (#32937)

* Don't prompt on force_persistent either

* Propagate persistence setting to lower paramiko connection
pull/33024/head
Nathaniel Case 7 years ago committed by GitHub
parent 1a2eb319fe
commit 37d8242e44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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…
Cancel
Save