From fec773a2b4999864b0e863b9d6b13892c19eaea9 Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Thu, 12 Jan 2017 19:31:35 -0500 Subject: [PATCH] better error handling and log messages in network_cli (#20204) --- lib/ansible/plugins/connection/network_cli.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/ansible/plugins/connection/network_cli.py b/lib/ansible/plugins/connection/network_cli.py index db01ec8ba0d..1df244f0f3b 100644 --- a/lib/ansible/plugins/connection/network_cli.py +++ b/lib/ansible/plugins/connection/network_cli.py @@ -72,16 +72,24 @@ class Connection(_Connection): network_os = self._play_context.network_os if not network_os: for cls in terminal_loader.all(class_only=True): - network_os = cls.guess_network_os(self.ssh) - if network_os: - break + try: + network_os = cls.guess_network_os(self.ssh) + if network_os: + break + except: + raise AnsibleConnectionFailure( + 'Unable to automatically determine host network os. ' + 'Please manually configure ansible_network_os value ' + 'for this host' + ) if not network_os: raise AnsibleConnectionFailure( - 'unable to determine device network os. Please configure ' - 'ansible_network_os value' + 'Unable to automatically determine host network os. Please ' + 'manually configure ansible_network_os value for this host' ) + self._terminal = terminal_loader.get(network_os, self) if not self._terminal: raise AnsibleConnectionFailure('network os %s is not supported' % network_os)