networktocode / ntc-ansible

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

ntc_file_copy - msg: '''CiscoIosFileTransfer'' object has no attribute ''scp_conn''' #250

Closed ericdost closed 1 year ago

ericdost commented 5 years ago

I'm getting the the following error when trying to use ntc_file_copy:

msg: '''CiscoIosFileTransfer'' object has no attribute ''scp_conn'''

Here is my current simple playbook:


- name: Upgrade Cisco IOS Devices
  hosts: IOS
  gather_facts: no

  vars:
    ntc_provider:
      host: "{{ ansible_host }}"
      username: "{{ ansible_user }}"
      password: "{{ ansible_ssh_pass }}"
      platform: "cisco_ios_ssh"

  tasks:

    - name: GATHERING FACTS
      ios_facts:
         gather_subset: hardware
      tags: always

    - name: Debug
      debug: 
        msg: 
          - "ansible_net_version is {{ ansible_net_version }}"
          - "standard_version is {{ standard_version }}"

    - name: COPYING IMAGE TO DEVICE FLASH
      ntc_file_copy:
#        provider: "{{ ntc_provider }}"
        host: "{{ ansible_host }}"
        username: "{{ ansible_user }}"
        password: "{{ ansible_ssh_pass }}"
        platform: "cisco_ios_ssh"
        local_file: "images/{{ standard_image }}"
      when: ansible_net_version != standard_version
      tags: copy

Here is the output when I use provider:

ansible-playbook 2.7.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/usr/share/ansible/plugins/modules/ntc-ansible', '/usr/local/lib/python2.7/dist-packages/ara/plugins/modules', '/home/ansible/.ansible/roles/mkouhei.include_csv']
  ansible python module location = /home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/ansible
  executable location = /home/ansible/venv/ansible_2_7_9/bin/ansible-playbook
  python version = 3.6.8 (default, Aug 20 2019, 17:12:48) [GCC 8.3.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
/home/ansible/inventory/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/home/ansible/inventory/hosts did not meet script requirements, check plugin documentation if this is unexpected
Parsed /home/ansible/inventory/hosts inventory source with ini plugin
Loading callback plugin yaml of type stdout, v2.0 from /home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/ansible/plugins/callback/yaml.py
 [WARNING]: Skipping plugin (/usr/local/lib/python2.7/dist-packages/ara/plugins/callbacks/log_ara.py) as it seems to be invalid: No module named 'ara'

Loading callback plugin profile_tasks of type aggregate, v2.0 from /home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/ansible/plugins/callback/profile_tasks.py

PLAYBOOK: upgradeios.yml *******************************************************************************************************************************************************************************************************************
1 plays in dev/upgradeios.yml

PLAY [Upgrade Cisco IOS Devices] ***********************************************************************************************************************************************************************************************************
META: ran handlers
Friday 20 September 2019  09:06:09 -0400 (0:00:00.114)       0:00:00.114 ****** 
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
<172.20.80.2> attempting to start connection
<172.20.80.2> using connection plugin network_cli
<172.20.80.2> local domain socket does not exist, starting it
<172.20.80.2> control socket path is /home/ansible/.ansible/pc/253bcf12f8
<172.20.80.2> <172.20.80.2> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: ansible on PORT 22 TO 172.20.80.2
<172.20.80.2> <172.20.80.2> ssh connection done, setting terminal
<172.20.80.2> <172.20.80.2> loaded terminal plugin for network_os ios
<172.20.80.2> <172.20.80.2> loaded cliconf plugin for network_os ios
<172.20.80.2> <172.20.80.2> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<172.20.80.2> <172.20.80.2> firing event: on_open_shell()
<172.20.80.2> <172.20.80.2> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<172.20.80.2> <172.20.80.2> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<172.20.80.2> <172.20.80.2> ssh connection has completed successfully
<172.20.80.2> connection to remote device started successfully
<172.20.80.2> local domain socket listeners started successfully
<172.20.80.2> 
<172.20.80.2> local domain socket path is /home/ansible/.ansible/pc/253bcf12f8
<172.20.80.2> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<172.20.80.2> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984773.0326087-32385313759497 `" && echo ansible-tmp-1568984773.0326087-32385313759497="` echo /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984773.0326087-32385313759497 `" ) && sleep 0'
Using module file /home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/ansible/modules/network/ios/ios_facts.py
<172.20.80.2> PUT /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/tmpw9ms7a_v TO /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984773.0326087-32385313759497/AnsiballZ_ios_facts.py
<172.20.80.2> EXEC /bin/sh -c 'chmod u+x /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984773.0326087-32385313759497/ /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984773.0326087-32385313759497/AnsiballZ_ios_facts.py && sleep 0'
<172.20.80.2> EXEC /bin/sh -c '/home/ansible/venv/ansible_2_7_9/bin/python /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984773.0326087-32385313759497/AnsiballZ_ios_facts.py && sleep 0'
<172.20.80.2> EXEC /bin/sh -c 'rm -f -r /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984773.0326087-32385313759497/ > /dev/null 2>&1 && sleep 0'

TASK [GATHERING FACTS] *********************************************************************************************************************************************************************************************************************
task path: /home/ansible/dev/upgradeios.yml:16
ok: [Switch] => changed=false 
  ansible_facts:
    ansible_net_filesystems:
    - 'flash:'
    ansible_net_filesystems_info:
      'flash:':
        spacefree_kb: 39655.0
        spacetotal_kb: 59598.0
    ansible_net_gather_subset:
    - hardware
    - default
    ansible_net_hostname: Switch
    ansible_net_image: flash:c2960sm-lanbasek9-mz.150-2.SE10.bin
    ansible_net_memfree_mb: 58291.12109375
    ansible_net_memtotal_mb: 78362.25390625
    ansible_net_model: SM-ES2-16-P
    ansible_net_serialnum: <snip>
    ansible_net_stacked_models:
    - SM-ES2-16-P
    ansible_net_stacked_serialnums:
    - <snip>
    ansible_net_version: 15.0(2)SE10
  invocation:
    module_args:
      auth_pass: null
      authorize: null
      gather_subset:
      - hardware
      host: null
      password: null
      port: null
      provider: null
      ssh_keyfile: null
      timeout: null
      username: null
Friday 20 September 2019  09:06:16 -0400 (0:00:06.967)       0:00:07.081 ****** 
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
<172.20.80.2> attempting to start connection
<172.20.80.2> using connection plugin network_cli
<172.20.80.2> found existing local domain socket, using it!
<172.20.80.2> updating play_context for connection
<172.20.80.2> 
<172.20.80.2> local domain socket path is /home/ansible/.ansible/pc/253bcf12f8

TASK [Debug] *******************************************************************************************************************************************************************************************************************************
task path: /home/ansible/dev/upgradeios.yml:21
ok: [Switch] => 
  msg:
  - ansible_net_version is 15.0(2)SE10
  - standard_version is 15.0(2)SE12
Friday 20 September 2019  09:06:16 -0400 (0:00:00.933)       0:00:08.015 ****** 
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
<172.20.80.2> attempting to start connection
<172.20.80.2> using connection plugin network_cli
<172.20.80.2> found existing local domain socket, using it!
<172.20.80.2> updating play_context for connection
<172.20.80.2> 
<172.20.80.2> local domain socket path is /home/ansible/.ansible/pc/253bcf12f8
<172.20.80.2> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<172.20.80.2> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984777.9104717-45884248550618 `" && echo ansible-tmp-1568984777.9104717-45884248550618="` echo /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984777.9104717-45884248550618 `" ) && sleep 0'
Using module file /usr/share/ansible/plugins/modules/ntc-ansible/library/ntc_file_copy.py
<172.20.80.2> PUT /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/tmpah533w7l TO /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984777.9104717-45884248550618/AnsiballZ_ntc_file_copy.py
<172.20.80.2> EXEC /bin/sh -c 'chmod u+x /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984777.9104717-45884248550618/ /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984777.9104717-45884248550618/AnsiballZ_ntc_file_copy.py && sleep 0'
<172.20.80.2> EXEC /bin/sh -c '/home/ansible/venv/ansible_2_7_9/bin/python /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984777.9104717-45884248550618/AnsiballZ_ntc_file_copy.py && sleep 0'
<172.20.80.2> EXEC /bin/sh -c 'rm -f -r /tmp/.ansible/tmp/ansible-local-10200czs9b8r3/ansible-tmp-1568984777.9104717-45884248550618/ > /dev/null 2>&1 && sleep 0'

TASK [COPYING IMAGE TO DEVICE FLASH] *******************************************************************************************************************************************************************************************************
task path: /home/ansible/dev/upgradeios.yml:27
The full traceback is:
  File "/tmp/ansible_ntc_file_copy_payload_b98pcc51/__main__.py", line 310, in main
    device.file_copy(local_file, remote_file)
  File "/home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/pyntc/devices/ios_device.py", line 223, in file_copy
    fc.close_scp_chan()
  File "/home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/netmiko/scp_handler.py", line 103, in close_scp_chan
    self.scp_conn.close()

fatal: [Switch]: FAILED! => changed=false 
  invocation:
    module_args:
      delay_factor: 1
      file_system: null
      global_delay_factor: 1
      host: 172.20.80.2
      key_file: null
      local_file: images/c2960sm-lanbasek9-mz.150-2.SE12.bin
      ntc_conf_file: null
      ntc_host: null
      password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      platform: cisco_ios_ssh
      port: null
      provider:
        delay_factor: 1
        global_delay_factor: 1
        host: 172.20.80.2
        key_file: null
        ntc_conf_file: null
        ntc_host: null
        password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
        platform: cisco_ios_ssh
        port: null
        secret: null
        transport: null
        use_keys: false
        username: ansible
      remote_file: null
      secret: null
      transport: null
      use_keys: false
      username: ansible
  msg: '''CiscoIosFileTransfer'' object has no attribute ''scp_conn'''

PLAY RECAP *********************************************************************************************************************************************************************************************************************************
Switch                     : ok=2    changed=0    unreachable=0    failed=1   

Friday 20 September 2019  09:06:39 -0400 (0:00:22.061)       0:00:30.076 ****** 
=============================================================================== 
COPYING IMAGE TO DEVICE FLASH ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 22.06s
/home/ansible/dev/upgradeios.yml:27 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GATHERING FACTS --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 6.97s
/home/ansible/dev/upgradeios.yml:16 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Debug ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.93s
/home/ansible/dev/upgradeios.yml:21 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
(ansible_2_7_9)

When I don't use provider, I get the same error message:

ansible-playbook 2.7.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/usr/share/ansible/plugins/modules/ntc-ansible', '/usr/local/lib/python2.7/dist-packages/ara/plugins/modules', '/home/ansible/.ansible/roles/mkouhei.include_csv']
  ansible python module location = /home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/ansible
  executable location = /home/ansible/venv/ansible_2_7_9/bin/ansible-playbook
  python version = 3.6.8 (default, Aug 20 2019, 17:12:48) [GCC 8.3.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
/home/ansible/inventory/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/home/ansible/inventory/hosts did not meet script requirements, check plugin documentation if this is unexpected
Parsed /home/ansible/inventory/hosts inventory source with ini plugin
Loading callback plugin yaml of type stdout, v2.0 from /home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/ansible/plugins/callback/yaml.py
 [WARNING]: Skipping plugin (/usr/local/lib/python2.7/dist-packages/ara/plugins/callbacks/log_ara.py) as it seems to be invalid: No module named 'ara'

Loading callback plugin profile_tasks of type aggregate, v2.0 from /home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/ansible/plugins/callback/profile_tasks.py

PLAYBOOK: upgradeios.yml *******************************************************************************************************************************************************************************************************************
1 plays in dev/upgradeios.yml

PLAY [Upgrade Cisco IOS Devices] ***********************************************************************************************************************************************************************************************************
META: ran handlers
Friday 20 September 2019  09:11:19 -0400 (0:00:00.116)       0:00:00.116 ****** 
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
<172.20.80.2> attempting to start connection
<172.20.80.2> using connection plugin network_cli
<172.20.80.2> local domain socket does not exist, starting it
<172.20.80.2> control socket path is /home/ansible/.ansible/pc/ccaa06bd16
<172.20.80.2> <172.20.80.2> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: ansible on PORT 22 TO 172.20.80.2
<172.20.80.2> <172.20.80.2> ssh connection done, setting terminal
<172.20.80.2> <172.20.80.2> loaded terminal plugin for network_os ios
<172.20.80.2> <172.20.80.2> loaded cliconf plugin for network_os ios
<172.20.80.2> <172.20.80.2> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<172.20.80.2> <172.20.80.2> firing event: on_open_shell()
<172.20.80.2> <172.20.80.2> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<172.20.80.2> <172.20.80.2> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<172.20.80.2> <172.20.80.2> ssh connection has completed successfully
<172.20.80.2> connection to remote device started successfully
<172.20.80.2> local domain socket listeners started successfully
<172.20.80.2> 
<172.20.80.2> local domain socket path is /home/ansible/.ansible/pc/ccaa06bd16
<172.20.80.2> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<172.20.80.2> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985083.4411-228278186451686 `" && echo ansible-tmp-1568985083.4411-228278186451686="` echo /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985083.4411-228278186451686 `" ) && sleep 0'
Using module file /home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/ansible/modules/network/ios/ios_facts.py
<172.20.80.2> PUT /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/tmpgw0rsd60 TO /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985083.4411-228278186451686/AnsiballZ_ios_facts.py
<172.20.80.2> EXEC /bin/sh -c 'chmod u+x /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985083.4411-228278186451686/ /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985083.4411-228278186451686/AnsiballZ_ios_facts.py && sleep 0'
<172.20.80.2> EXEC /bin/sh -c '/home/ansible/venv/ansible_2_7_9/bin/python /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985083.4411-228278186451686/AnsiballZ_ios_facts.py && sleep 0'
<172.20.80.2> EXEC /bin/sh -c 'rm -f -r /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985083.4411-228278186451686/ > /dev/null 2>&1 && sleep 0'

TASK [GATHERING FACTS] *********************************************************************************************************************************************************************************************************************
task path: /home/ansible/dev/upgradeios.yml:16
ok: [Switch] => changed=false 
  ansible_facts:
    ansible_net_filesystems:
    - 'flash:'
    ansible_net_filesystems_info:
      'flash:':
        spacefree_kb: 39655.0
        spacetotal_kb: 59598.0
    ansible_net_gather_subset:
    - hardware
    - default
    ansible_net_hostname: Switch
    ansible_net_image: flash:c2960sm-lanbasek9-mz.150-2.SE10.bin
    ansible_net_memfree_mb: 58291.12109375
    ansible_net_memtotal_mb: 78362.25390625
    ansible_net_model: SM-ES2-16-P
    ansible_net_serialnum: <snip>
    ansible_net_stacked_models:
    - SM-ES2-16-P
    ansible_net_stacked_serialnums:
    - <snip>
    ansible_net_version: 15.0(2)SE10
  invocation:
    module_args:
      auth_pass: null
      authorize: null
      gather_subset:
      - hardware
      host: null
      password: null
      port: null
      provider: null
      ssh_keyfile: null
      timeout: null
      username: null
Friday 20 September 2019  09:11:26 -0400 (0:00:06.873)       0:00:06.990 ****** 
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
<172.20.80.2> attempting to start connection
<172.20.80.2> using connection plugin network_cli
<172.20.80.2> found existing local domain socket, using it!
<172.20.80.2> updating play_context for connection
<172.20.80.2> 
<172.20.80.2> local domain socket path is /home/ansible/.ansible/pc/ccaa06bd16

TASK [Debug] *******************************************************************************************************************************************************************************************************************************
task path: /home/ansible/dev/upgradeios.yml:21
ok: [Switch] => 
  msg:
  - ansible_net_version is 15.0(2)SE10
  - standard_version is 15.0(2)SE12
Friday 20 September 2019  09:11:27 -0400 (0:00:00.856)       0:00:07.846 ****** 
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
Trying secret FileVaultSecret(filename='/home/ansible/inventory/group_vars/vault_pass.txt') for vault_id=default
<172.20.80.2> attempting to start connection
<172.20.80.2> using connection plugin network_cli
<172.20.80.2> found existing local domain socket, using it!
<172.20.80.2> updating play_context for connection
<172.20.80.2> 
<172.20.80.2> local domain socket path is /home/ansible/.ansible/pc/ccaa06bd16
<172.20.80.2> ESTABLISH LOCAL CONNECTION FOR USER: ansible
<172.20.80.2> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985088.1924286-62403270059720 `" && echo ansible-tmp-1568985088.1924286-62403270059720="` echo /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985088.1924286-62403270059720 `" ) && sleep 0'
Using module file /usr/share/ansible/plugins/modules/ntc-ansible/library/ntc_file_copy.py
<172.20.80.2> PUT /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/tmpejuitmr4 TO /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985088.1924286-62403270059720/AnsiballZ_ntc_file_copy.py
<172.20.80.2> EXEC /bin/sh -c 'chmod u+x /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985088.1924286-62403270059720/ /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985088.1924286-62403270059720/AnsiballZ_ntc_file_copy.py && sleep 0'
<172.20.80.2> EXEC /bin/sh -c '/home/ansible/venv/ansible_2_7_9/bin/python /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985088.1924286-62403270059720/AnsiballZ_ntc_file_copy.py && sleep 0'
<172.20.80.2> EXEC /bin/sh -c 'rm -f -r /tmp/.ansible/tmp/ansible-local-10429dq0f1ntc/ansible-tmp-1568985088.1924286-62403270059720/ > /dev/null 2>&1 && sleep 0'

TASK [COPYING IMAGE TO DEVICE FLASH] *******************************************************************************************************************************************************************************************************
task path: /home/ansible/dev/upgradeios.yml:27
The full traceback is:
  File "/tmp/ansible_ntc_file_copy_payload_o_gtkcn_/__main__.py", line 310, in main
    device.file_copy(local_file, remote_file)
  File "/home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/pyntc/devices/ios_device.py", line 223, in file_copy
    fc.close_scp_chan()
  File "/home/ansible/venv/ansible_2_7_9/lib/python3.6/site-packages/netmiko/scp_handler.py", line 103, in close_scp_chan
    self.scp_conn.close()

fatal: [Switch]: FAILED! => changed=false 
  invocation:
    module_args:
      delay_factor: 1
      file_system: null
      global_delay_factor: 1
      host: 172.20.80.2
      key_file: null
      local_file: images/c2960sm-lanbasek9-mz.150-2.SE12.bin
      ntc_conf_file: null
      ntc_host: null
      password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      platform: cisco_ios_ssh
      port: null
      provider: null
      remote_file: null
      secret: null
      transport: null
      use_keys: false
      username: ansible
  msg: '''CiscoIosFileTransfer'' object has no attribute ''scp_conn'''

PLAY RECAP *********************************************************************************************************************************************************************************************************************************
Switch                     : ok=2    changed=0    unreachable=0    failed=1   

Friday 20 September 2019  09:11:49 -0400 (0:00:21.811)       0:00:29.657 ****** 
=============================================================================== 
COPYING IMAGE TO DEVICE FLASH ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 21.81s
/home/ansible/dev/upgradeios.yml:27 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GATHERING FACTS --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 6.87s
/home/ansible/dev/upgradeios.yml:16 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Debug ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0.86s
/home/ansible/dev/upgradeios.yml:21 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
jmcgill298 commented 5 years ago

I believe the finally clause in pyntc is masking an exception in establishing the scp connection and transferring the file. The netmiko code does not create a scp_conn attribute on initialization, but is created during a call to the establish_scp_conn method. I am guessing that there is failure before this, and so when the finally clause tries to close the connection, another exception is raised since the scp_conn attribute hasn't been created.

Can you install pyntc from: https://github.com/networktocode/pyntc/tree/file_transfer and try again? I don't think this will resolve the issue, but I think it will highlight the actual issue with transferring the file (likely the call to enabling scp on the device).

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.