networktocode / ntc-ansible

Multi-vendor network modules
Other
278 stars 112 forks source link

Need help in troubleshooting when using ntc_file_copy #214

Closed nncse closed 1 year ago

nncse commented 6 years ago

Hello again! Hope you guys are well.

I am testing ntc_file_copy to upload IOS-XE images to a couple of Cisco ISRs. When a manual scp command is used from the Ansible host to the router, it works but when I used Ansible it does not. Please note that I have another playbook for just plain IOS devices and that works.

Thanks in advance.

nncse@netmon3:~/ansible-files$ scp ~/Downloads/isr4300-universalk9.16.06.03.SPA.bin admin@ch0i1-v1:/isr4300-universalk9.16.06.03.SPA.bin
Password:
isr4300-universalk9.16.06.03.SPA.bin                                                           0% 2176KB   1.1MB/s   08:11 ETA^

TRACEBACK error when running Ansible playbook;

Traceback (most recent call last):
  File "/tmp/ansible_aU0ebx/ansible_module_ntc_file_copy.py", line 274, in <module>
    main()
  File "/tmp/ansible_aU0ebx/ansible_module_ntc_file_copy.py", line 241, in main
    remote_exists = device.file_copy_remote_exists(local_file, remote_file, file_system=file_system)
  File "/usr/local/lib/python2.7/dist-packages/pyntc-0.0.5-py2.7.egg/pyntc/devices/ios_device.py", line 141, in file_copy_remote_exists
    if fc.check_file_exists() and fc.compare_md5():
  File "build/bdist.linux-i686/egg/netmiko/scp_handler.py", line 138, in check_file_exists
ValueError: Unexpected output from check_file_exists

fatal: [ch0i1-v1]: FAILED! => {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_name": "ntc_file_copy"
    },
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_aU0ebx/ansible_module_ntc_file_copy.py\", line 274, in <module>\n    main()\n  File \"/tmp/ansible_aU0ebx/ansible_module_ntc_file_copy.py\", line 241, in main\n    remote_exists = device.file_copy_remote_exists(local_file, remote_file, file_system=file_system)\n  File \"/usr/local/lib/python2.7/dist-packages/pyntc-0.0.5-py2.7.egg/pyntc/devices/ios_device.py\", line 141, in file_copy_remote_exists\n    if fc.check_file_exists() and fc.compare_md5():\n  File \"build/bdist.linux-i686/egg/netmiko/scp_handler.py\", line 138, in check_file_exists\nValueError: Unexpected output from check_file_exists\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE"

My playbook:

    - name: COPY IMAGE TO DEVICE
      ntc_file_copy:
        platform: cisco_ios_ssh
        local_file: /home/nncse/Downloads/{{ ios_xe_isr_version }}
        remote_file: "{{ ios_xe_isr_version }}"
        host: "{{ inventory_hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        port: 22
        file_system: "bootflash:"
      register: scp_ios_xe_isr_status
      when: dir_ios_xe_isr.stdout_lines != "{{ ios_xe_isr_version }}"

    - debug: msg="{{ scp_ios_xe_isr_status.transfer_status }} to {{ inventory_hostname }}. The image is in the device"

My group_vars yaml file:

ios_xe_isr_version: isr4300-universalk9.16.06.03.SPA.bin
jeffkala commented 1 year ago

closing. Please retest now that #268 is deployed and 1.0.0 of this collection is in ansible-galaxy now.