Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to transfer files using SCP to a Cisco IOS device #325

Closed
vrelk opened this issue May 5, 2022 · 1 comment · Fixed by #620
Closed

Unable to transfer files using SCP to a Cisco IOS device #325

vrelk opened this issue May 5, 2022 · 1 comment · Fixed by #620
Assignees

Comments

@vrelk
Copy link

vrelk commented May 5, 2022

SUMMARY

When attempting to transfer a file using SCP to an IOS device, you get a "No such file or directory" error. If you switch back to Paramiko it works fine.

ISSUE TYPE
  • Bug Report
PYLISSH and LIBSSH VERSION
libssh_0.9.3
ansible_pylibssh-0.4.0
OS / ENVIRONMENT

This is running from a custom EE based off of quay.io/ansible/awx-ee:0.6.0. The only additions are some extra packages for netbox, scp, and pylibssh.

The target is a Cisco 3750xp running IOS 15.2(4)E8. I have run this with ssh1 and ssh2 enabled on the switch, and both ended with the same result.

STEPS TO REPRODUCE

Running this task

- name: transfering upgrade image to switch...
  block:
    - ansible.netcommon.net_put:
        src: "../files/c3750e-universalk9-mz.152-4.E10.bin"
        dest: "flash:c3750e-universalk9-mz.152-4.E10.bin"
  when: ansible_network_os == 'cisco.ios.ios'
EXPECTED RESULTS

This is actually the output when you add the var ansible_network_cli_ssh_type: paramiko, nothing else was changed between this run and the failed one using libssh.

SSH Logs from the switch: https://gist.github.com/vrelk/da99ec3107e18d7239f0286ee582e2c9 (start/end trimmed)

TASK [upgrade : ansible.netcommon.net_put] *************************************
task path: /runner/project/roles/upgrade/tasks/xfer.yml:3
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<10.255.79.10> attempting to start connection
<10.255.79.10> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/local/bin/ansible-connection
<10.255.79.10> found existing local domain socket, using it!
<10.255.79.10> updating play_context for connection
<10.255.79.10> 
<10.255.79.10> local domain socket path is /home/runner/.ansible/pc/11ab5503fd
Getting network OS from inventory
changed: [3750xp-stack] => {
    "changed": true,
    "destination": "flash:c3750e-universalk9-mz.152-4.E10.bin"
}
ACTUAL RESULTS

This is the debug output on the switch that corresponds to this task (with ssh and scp debugging enabled): https://gist.github.com/vrelk/23fa0dfd09b8f27f79118684bac75d08

TASK [upgrade : ansible.netcommon.net_put] *************************************
task path: /runner/project/roles/upgrade/tasks/xfer.yml:3
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<10.255.79.10> attempting to start connection
<10.255.79.10> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /usr/local/bin/ansible-connection
<10.255.79.10> found existing local domain socket, using it!
<10.255.79.10> updating play_context for connection
<10.255.79.10> 
<10.255.79.10> local domain socket path is /home/runner/.ansible/pc/11ab5503fd
Getting network OS from inventory
fatal: [3750xp-stack]: FAILED! => {
    "changed": false,
    "destination": "flash:c3750e-universalk9-mz.152-4.E10.bin",
    "msg": "Exception received: Error transferring file to flash:c3750e-universalk9-mz.152-4.E10.bin: Initializing SCP session of remote file [flash:c3750e-universalk9-mz.152-4.E10.bin] for write failed with error [b'Socket error: No such file or directory']"
}
@Qalthos Qalthos self-assigned this May 11, 2022
@Andyjb8
Copy link

Andyjb8 commented May 10, 2023

I am having a very similar issue copying files to IOS devices with net_put. It works with paramiko but not with libssh. This issue may be related to #500

Here is my playbook:

  • hosts: rtr01
    tasks:
    - name: PUSH TEST FILE TO DEVICE
    ansible.netcommon.net_put:
    src: /home/software/cisco/.tgz
    dest: flash:/.tgz
    vars:
    ansible_connection: network_cli
    ansible_network_cli_ssh_type: paramiko

It works when I specify "ansible_network_cli_ssh_type: paramiko" variable, but without specifying paramiko and using libssh it fails with this error:
"Exception received unable to connect to socket /home//.ansible/pc/17de54cbc6. See the socket path issue category in Network Debug and Troubleshooting guide."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants