diff --git a/lib/ansible/plugins/connection/netconf.py b/lib/ansible/plugins/connection/netconf.py index 5cf4a442a7..56fad9c53b 100644 --- a/lib/ansible/plugins/connection/netconf.py +++ b/lib/ansible/plugins/connection/netconf.py @@ -164,6 +164,7 @@ class Connection(ConnectionBase): allow_agent = True if self._play_context.password is not None: allow_agent = False + setattr(self._play_context, 'allow_agent', allow_agent) key_filename = None if self._play_context.private_key_file: @@ -195,7 +196,7 @@ class Connection(ConnectionBase): key_filename=str(key_filename), hostkey_verify=C.HOST_KEY_CHECKING, look_for_keys=C.PARAMIKO_LOOK_FOR_KEYS, - allow_agent=allow_agent, + allow_agent=self._play_context.allow_agent, timeout=self._play_context.timeout, device_params={'name': network_os}, ssh_config=ssh_config diff --git a/lib/ansible/plugins/netconf/iosxr.py b/lib/ansible/plugins/netconf/iosxr.py index e97a7dc3bc..eee3eade14 100644 --- a/lib/ansible/plugins/netconf/iosxr.py +++ b/lib/ansible/plugins/netconf/iosxr.py @@ -141,10 +141,10 @@ class Netconf(NetconfBase): port=obj._play_context.port or 830, username=obj._play_context.remote_user, password=obj._play_context.password, - key_filename=str(obj.key_filename), + key_filename=obj._play_context.private_key_file, hostkey_verify=C.HOST_KEY_CHECKING, look_for_keys=C.PARAMIKO_LOOK_FOR_KEYS, - allow_agent=obj.allow_agent, + allow_agent=obj._play_context.allow_agent, timeout=obj._play_context.timeout ) except SSHUnknownHostError as exc: diff --git a/lib/ansible/plugins/netconf/junos.py b/lib/ansible/plugins/netconf/junos.py index cb61e62869..1c29f85253 100644 --- a/lib/ansible/plugins/netconf/junos.py +++ b/lib/ansible/plugins/netconf/junos.py @@ -107,10 +107,10 @@ class Netconf(NetconfBase): port=obj._play_context.port or 830, username=obj._play_context.remote_user, password=obj._play_context.password, - key_filename=str(obj.key_filename), + key_filename=obj._play_context.private_key_file, hostkey_verify=C.HOST_KEY_CHECKING, look_for_keys=C.PARAMIKO_LOOK_FOR_KEYS, - allow_agent=obj.allow_agent, + allow_agent=obj._play_context.allow_agent, timeout=obj._play_context.timeout ) except SSHUnknownHostError as exc: