mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fixes using ssh keyfile with junos network module
The junos network module will now properly use the ssh key file if its passed from the playbook to authenticate to the remote device. Prior to this commit, the ssh keyfile was ignored.
This commit is contained in:
parent
349b06974e
commit
59e1bb3e6e
1 changed files with 6 additions and 2 deletions
|
@ -93,9 +93,12 @@ class Cli(object):
|
||||||
password = self.module.params['password']
|
password = self.module.params['password']
|
||||||
key_filename = self.module.params['ssh_keyfile']
|
key_filename = self.module.params['ssh_keyfile']
|
||||||
|
|
||||||
|
allow_agent = (key_filename is not None) or (key_filename is None and password is None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.shell = Shell()
|
self.shell = Shell()
|
||||||
self.shell.open(host, port=port, username=username, password=password, key_filename=key_filename, allow_agent=True)
|
self.shell.open(host, port=port, username=username, password=password,
|
||||||
|
key_filename=key_filename, allow_agent=allow_agent)
|
||||||
except ShellError:
|
except ShellError:
|
||||||
e = get_exception()
|
e = get_exception()
|
||||||
msg = 'failed to connect to %s:%s - %s' % (host, port, str(e))
|
msg = 'failed to connect to %s:%s - %s' % (host, port, str(e))
|
||||||
|
@ -152,9 +155,10 @@ class Netconf(object):
|
||||||
|
|
||||||
user = self.module.params['username']
|
user = self.module.params['username']
|
||||||
passwd = self.module.params['password']
|
passwd = self.module.params['password']
|
||||||
|
key_filename = self.module.params['ssh_keyfile']
|
||||||
|
|
||||||
self.device = Device(host, user=user, passwd=passwd, port=port,
|
self.device = Device(host, user=user, passwd=passwd, port=port,
|
||||||
gather_facts=False).open()
|
gather_facts=False, ssh_private_key_file=key_filename).open()
|
||||||
|
|
||||||
self.config = Config(self.device)
|
self.config = Config(self.device)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue