Skip to content

Commit

Permalink
Merge pull request ansible#16181 from privateip/working
Browse files Browse the repository at this point in the history
fixes issue with ssh keyfile and nxos authentication
  • Loading branch information
privateip committed Jun 8, 2016
2 parents d91315f + 178cfd1 commit bd8b041
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/ansible/module_utils/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
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']
Expand Down Expand Up @@ -168,11 +169,17 @@ def connect(self, **kwargs):

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))
Expand Down

0 comments on commit bd8b041

Please sign in to comment.