mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
more debug logs for free, network_cli, paramiko and add hostname context to debugging messages (#39205)
* Add hostname context to debugging messages * Set paramiko's channel
This commit is contained in:
parent
f91d961cb4
commit
bbfe7a8b2f
4 changed files with 30 additions and 11 deletions
|
@ -228,6 +228,7 @@ class Connection(ConnectionBase):
|
|||
''' SSH based connections with Paramiko '''
|
||||
|
||||
transport = 'paramiko'
|
||||
_log_channel = None
|
||||
|
||||
def _cache_key(self):
|
||||
return "%s__%s__" % (self._play_context.remote_addr, self._play_context.remote_user)
|
||||
|
@ -240,6 +241,10 @@ class Connection(ConnectionBase):
|
|||
self.ssh = SSH_CONNECTION_CACHE[cache_key] = self._connect_uncached()
|
||||
return self
|
||||
|
||||
def _set_log_channel(self, name):
|
||||
'''Mimic paramiko.SSHClient.set_log_channel'''
|
||||
self._log_channel = name
|
||||
|
||||
def _parse_proxy_command(self, port=22):
|
||||
proxy_command = None
|
||||
# Parse ansible_ssh_common_args, specifically looking for ProxyCommand
|
||||
|
@ -297,6 +302,10 @@ class Connection(ConnectionBase):
|
|||
|
||||
ssh = paramiko.SSHClient()
|
||||
|
||||
# override paramiko's default logger name
|
||||
if self._log_channel is not None:
|
||||
ssh.set_log_channel(self._log_channel)
|
||||
|
||||
self.keyfile = os.path.expanduser("~/.ssh/known_hosts")
|
||||
|
||||
if self.get_option('host_key_checking'):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue