diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py index 786e415c48..16f2057866 100644 --- a/lib/ansible/module_utils/junos.py +++ b/lib/ansible/module_utils/junos.py @@ -105,8 +105,10 @@ class Netconf(object): self._connected = True def disconnect(self): - if self.device: + try: self.device.close() + except AttributeError: + pass self._connected = False ### Command methods ###