summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Sprygada <psprygada@ansible.com>2016-06-07 21:00:02 -0400
committerPeter Sprygada <psprygada@ansible.com>2016-06-07 21:28:31 -0400
commitd4c78b84f0df79b2bff6590e71177bd2d7cd01f9 (patch)
tree2d1ec98effef452638d424af20bc84d57f5f4b00
parent405f636cc74b982ccf18eee9c3601cda354f3385 (diff)
downloadansible-d4c78b84f0df79b2bff6590e71177bd2d7cd01f9.tar.gz
fixes issue with ssh keyfile and nxos authentication
The nxos cli provider would not properly handle ssh key files passed from the playbook task. The ssh_keyfile argument is now properly passed to the ssh authentication method This fix address the bug reported in #3862
-rw-r--r--lib/ansible/module_utils/nxos.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/ansible/module_utils/nxos.py b/lib/ansible/module_utils/nxos.py
index 578c7e5f99..13ab23a013 100644
--- a/lib/ansible/module_utils/nxos.py
+++ b/lib/ansible/module_utils/nxos.py
@@ -35,7 +35,8 @@ NET_COMMON_ARGS = dict(
transport=dict(default='cli', choices=['cli', 'nxapi']),
use_ssl=dict(default=False, type='bool'),
validate_certs=dict(default=True, type='bool'),
- provider=dict(type='dict')
+ provider=dict(type='dict'),
+ timeout=dict(default=10, type='int')
)
NXAPI_COMMAND_TYPES = ['cli_show', 'cli_show_ascii', 'cli_conf', 'bash']
@@ -168,11 +169,17 @@ class Cli(object):
username = self.module.params['username']
password = self.module.params['password']
+ timeout = self.module.params['timeout']
key_filename = self.module.params['ssh_keyfile']
+ allow_agent = (key_filename is not None) or (key_filename is None and password is None)
+
try:
- self.shell = Shell(kickstart=False, prompts_re=CLI_PROMPTS_RE, errors_re=CLI_ERRORS_RE)
- self.shell.open(host, port=port, username=username, password=password, key_filename=key_filename)
+ self.shell = Shell(kickstart=False, prompts_re=CLI_PROMPTS_RE,
+ errors_re=CLI_ERRORS_RE)
+ self.shell.open(host, port=port, username=username,
+ password=password, key_filename=key_filename,
+ allow_agent=allow_agent, timeout=timeout)
except ShellError:
e = get_exception()
msg = 'failed to connect to %s:%s - %s' % (host, port, str(e))