From 9e31e33850a220ffda09d685d51b1eddb100116d Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Wed, 17 Feb 2016 14:15:11 +0000 Subject: [PATCH] minor bugfix that will catch connection errors in nxos This commit fixes a situation where connection errors would be caught but no useful information display. The connection error is now caught and emitted in a call to fail_json --- lib/ansible/module_utils/nxos.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/module_utils/nxos.py b/lib/ansible/module_utils/nxos.py index 8c681830a6..e18aea4773 100644 --- a/lib/ansible/module_utils/nxos.py +++ b/lib/ansible/module_utils/nxos.py @@ -147,7 +147,8 @@ class Cli(object): try: self.shell.open(host, port=port, username=username, password=password) except Exception, exc: - self.module.fail_json('Failed to connect to {0}:{1} - {2}'.format(host, port, str(exc))) + msg = 'failed to connecto to %s:%s - %s' % (host, port, str(exc)) + self.module.fail_json(msg=msg) def send(self, commands, encoding='text'): return self.shell.send(commands) @@ -188,7 +189,7 @@ class NetworkModule(AnsibleModule): def configure(self, commands): commands = to_list(commands) if self.params['transport'] == 'cli': - commands.insert(0, 'configure terminal') + commands.insert(0, 'configure') responses = self.execute(commands) responses.pop(0) else: