ansible.netcommon
ansible.netcommon copied to clipboard
Module net_get failing with libssh while working with paramiko
SUMMARY
Hello,
we are planning to switch from ansible connection type paramiko
to libssh
and found that net_get
module fails during our testing with libssh
while it works fine with paramiko
.
ISSUE TYPE
- Bug Report
COMPONENT NAME
Module ansilble.netcommon.net_get
ANSIBLE VERSION
ansible [core 2.12.2]
config file = ansible.cfg
configured module search path = ['/home/user/plugins/modules']
ansible python module location = /home/user/.venv/core212/lib/python3.8/site-packages/ansible
ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
executable location = /home/user/.venv/core212/bin/ansible
python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
jinja version = 3.0.3
libyaml = True
COLLECTION VERSION
Collection Version
----------------- -------
ansible.netcommon 3.0.1
OS / ENVIRONMENT
Ansible controller: Ubuntu 20.04 Target ASA device: Cisco Adaptive Security Appliance Software Version 9.12(4)38
STEPS TO REPRODUCE
Following module is trying to SCP file from ASA device to the ansible controller:
---
- name: asa_get_backup
hosts: ASA0102
gather_facts: no
connection: network_cli
collections: cisco.asa
tasks:
- name: "Get config file"
net_get:
src: "admin.cfg"
protocol: scp
dest: "/tmp/ASA0102_admin.cfg"
EXPECTED RESULTS
File admin.cfg
is downloaded to the ansible controller at specified path.
ACTUAL RESULTS
The module fails with following error:
Loading collection cisco.asa from /usr/share/ansible/collections/ansible_collections/cisco/asa
PLAYBOOK: asa_get_backup.yaml **************************************************
TASK [firewalling/asa_get_backup : Get context config files from device] *******
task path: /runner/project/roles/firewall/asa_get_backup/tasks/main.yml:57
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<10.10.10.10> attempting to start connection
<10.10.10.10> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/local/bin/ansible-connection
<10.10.10.10> found existing local domain socket, using it!
<10.10.10.10> updating play_context for connection
<10.10.10.10>
<10.10.10.10> local domain socket path is /home/runner/.ansible/pc/790de8c7f5
Getting network OS from inventory
Getting network OS from inventory
failed: [ASA0102] => {
"changed": true,
"destination": "/tmp/ASA0102_admin.cfg",
"msg": "Exception received: Error transferring file from /tmp/ASA0102_admin.cfg: Initializing SCP session of remote file [/tmp/ASA0102_admin.cfg] for write failed with error [b'Socket error: Success']"
}
We found that this is because we're using libssh
as connection type. When we force the connection type to paramiko
, the module successfully downloads the file.
Can you please check and see if you can make the net_get
module work properly with libssh
?
Note - there is an existing issue #211 for failure to scp a file from ASA device, but the description of the issue and the error message are different, hence opened a separate issue.
Hello, will this be considered for review?
I have the same issue, wrote about it on https://www.reddit.com/r/ansible/comments/1arbb2a/ansiblenetcommonnet_get_copy_file_does_not_work/
maybe open a new issue within https://github.com/ansible/pylibssh/issues
and for SFTP , seems like it is missing b parameter so file is treated like binary.
Same error.
Need to force ansible_network_cli_ssh_type: paramiko
paramiko has other limitations by design, so this is not an option.