diff --git a/changelogs/netconf_reset_connection.yaml b/changelogs/netconf_reset_connection.yaml new file mode 100644 index 000000000..199b1f977 --- /dev/null +++ b/changelogs/netconf_reset_connection.yaml @@ -0,0 +1,7 @@ +--- +bugfixes: + - "Connection can be lost from control plane reset or device restart. meta: + reset_connection task will attempt to send a session_close RPC to a dead + connection and ncclient will raise an exception preventing the connection + socket_path from being closed out. + (https://github.com/ansible-collections/ansible.netcommon/issues/348)" diff --git a/plugins/connection/netconf.py b/plugins/connection/netconf.py index 0fc3184e0..0c8b54def 100644 --- a/plugins/connection/netconf.py +++ b/plugins/connection/netconf.py @@ -430,6 +430,6 @@ def _connect(self): ) def close(self): - if self._manager: + if self._manager and self._manager.connected: self._manager.close_session() super(Connection, self).close()