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.
... | ... |
@@ -93,9 +93,12 @@ class Cli(object): |
93 | 93 |
password = self.module.params['password'] |
94 | 94 |
key_filename = self.module.params['ssh_keyfile'] |
95 | 95 |
|
96 |
+ allow_agent = (key_filename is not None) or (key_filename is None and password is None) |
|
97 |
+ |
|
96 | 98 |
try: |
97 | 99 |
self.shell = Shell() |
98 |
- self.shell.open(host, port=port, username=username, password=password, key_filename=key_filename, allow_agent=True) |
|
100 |
+ self.shell.open(host, port=port, username=username, password=password, |
|
101 |
+ key_filename=key_filename, allow_agent=allow_agent) |
|
99 | 102 |
except ShellError: |
100 | 103 |
e = get_exception() |
101 | 104 |
msg = 'failed to connect to %s:%s - %s' % (host, port, str(e)) |
... | ... |
@@ -152,9 +155,10 @@ class Netconf(object): |
152 | 152 |
|
153 | 153 |
user = self.module.params['username'] |
154 | 154 |
passwd = self.module.params['password'] |
155 |
+ key_filename = self.module.params['ssh_keyfile'] |
|
155 | 156 |
|
156 | 157 |
self.device = Device(host, user=user, passwd=passwd, port=port, |
157 |
- gather_facts=False).open() |
|
158 |
+ gather_facts=False, ssh_private_key_file=key_filename).open() |
|
158 | 159 |
|
159 | 160 |
self.config = Config(self.device) |
160 | 161 |
|