Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/ansible.netcommon.netconf_connection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,32 @@ Parameters
<div>Can be configured from the CLI via the <code>--user</code> or <code>-u</code> options.</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>use_libssh</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
</ul>
</td>
<td>
<div> ini entries:
<p>[defaults]<br>netconf_libssh = yes</p>
</div>
<div>env:ANSIBLE_NETCONF_LIBSSH</div>
<div>var: ansible_netconf_libssh</div>
</td>
<td>
<div>specifies weather to use libssh for netconf connection or not</div>
</td>
</tr>
</table>
<br/>

Expand Down
27 changes: 25 additions & 2 deletions plugins/connection/netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@
- name: ANSIBLE_REMOTE_PORT
vars:
- name: ansible_port
use_libssh:
type: bool
description:
- specifies weather to use libssh for netconf connection or not
default: true
ini:
- section: defaults
key: netconf_libssh
env:
- name: ANSIBLE_NETCONF_LIBSSH
vars:
- name: ansible_netconf_libssh
network_os:
description:
- Configures the device platform network operating system. This value is used
Expand Down Expand Up @@ -314,6 +326,8 @@ def _connect(self):
self.queue_message("log", "ssh connection done, starting ncclient")

allow_agent = True
use_libssh = self.get_option("use_libssh")

if self._play_context.password is not None:
allow_agent = False
setattr(self._play_context, "allow_agent", allow_agent)
Expand Down Expand Up @@ -378,12 +392,21 @@ def _connect(self):
password=self._play_context.password,
key_filename=self.key_filename,
hostkey_verify=self.get_option("host_key_checking"),
look_for_keys=self.get_option("look_for_keys"),
device_params=device_params,
allow_agent=self._play_context.allow_agent,
timeout=self.get_option("persistent_connect_timeout"),
ssh_config=self._ssh_config,
)
# use_libssh option is only supported with ncclient >= 0.7.0
if use_libssh:
self.queue_message(
"warning",
"ncclient >= 0.7.0 does not support ssh_config file option while using libssh as a transport",
)
params["use_libssh"] = use_libssh
else:
params["look_for_keys"] = self.get_option("look_for_keys")
params["ssh_config"] = self._ssh_config

# sock is only supported by ncclient >= 0.6.10, and will error if
# included on older versions. We check the version in
# _get_proxy_command, so if this returns a value, the version is
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ paramiko
xmltodict
grpcio
protobuf
ssh-python
Loading