From 92e4a982196d514fb4ceb572d9ca8d952f5ada54 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Fri, 24 May 2019 14:54:22 -0400 Subject: [PATCH] [stable-2.8] Don't fail trying to read boot image without enable (#56126) (#56134) * [stable-2.8] Don't fail trying to read boot image without enable (#56126) Also add a message when network_os_image can't be acquired. (cherry picked from commit 3d9da0c) Co-authored-by: Nathaniel Case * Add changelog * Fix changelog --- changelogs/fragments/56126-eos-without-become.yaml | 2 ++ lib/ansible/plugins/cliconf/eos.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/56126-eos-without-become.yaml diff --git a/changelogs/fragments/56126-eos-without-become.yaml b/changelogs/fragments/56126-eos-without-become.yaml new file mode 100644 index 00000000000..0ad178a8727 --- /dev/null +++ b/changelogs/fragments/56126-eos-without-become.yaml @@ -0,0 +1,2 @@ +bugfixes: +- "eos: don't fail modules without become set, instead show message and continue" 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