From 3d9da0c468544becb5f4815e0565002b037e4ca0 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Mon, 6 May 2019 15:15:26 -0400 Subject: [PATCH] Don't fail trying to read boot image without enable (#56126) Also add a message when network_os_image can't be acquired. --- lib/ansible/plugins/cliconf/eos.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/ansible/plugins/cliconf/eos.py b/lib/ansible/plugins/cliconf/eos.py index 7464f2f6ed5..291788d1962 100644 --- a/lib/ansible/plugins/cliconf/eos.py +++ b/lib/ansible/plugins/cliconf/eos.py @@ -247,10 +247,15 @@ class Cliconf(CliconfBase): device_info['network_os_hostname'] = data['hostname'] - reply = self.get('bash timeout 5 cat /mnt/flash/boot-config') - match = re.search(r'SWI=(.+)$', reply, re.M) - if match: - device_info['network_os_image'] = match.group(1) + try: + reply = self.get('bash timeout 5 cat /mnt/flash/boot-config') + + match = re.search(r'SWI=(.+)$', reply, re.M) + if match: + device_info['network_os_image'] = match.group(1) + except AnsibleConnectionFailure: + # This requires enable mode to run + self._connection.queue_message('vvv', "Unable to gather network_os_image without enable mode") return device_info