ansible-collections / ansible.netcommon

Ansible Network Collection for Common Code
GNU General Public License v3.0
145 stars 105 forks source link

Ansible copying Cisco Bin File locally/remotely at the same time #617

Open Akasurde opened 10 months ago

Akasurde commented 10 months ago

Summary

When transferring a new IOS file to a Cisco Router, an unexpected behavior occurs where a copy of the IOS file also gets created locally (in the project folder) as a random UUID name.

So not only is the bin file being copied to the router, it is also being copied to where I store my ansible project and where I am executing the playbooks from. The way I understand it, the copy module & net_put module are supposed to only copy the file to the remote destination. And what's also interesting, is that I have other playbooks that use the copy module and work perfectly fine/does not replicate this behavior.

Another interesting behavior I am noticing is, if I force the inventory file to use the wrong ssh password, the copy/net_put task reports 'changed'/'ok', placing the bin file in my project folder (but since the password is wrong, it does not get placed on the router). I know it's accessing the host designated in the playbook correctly because the task after the copy/net_put tries to run but cannot (since I forced the password wrong).

Issue Type

Bug Report

Component Name

net_put copy

Ansible Version

ansible [core 2.16.2]
  config file = /home/labtesting/.ansible.cfg
  configured module search path = ['/home/labtesting/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/labtesting/venv/lib/python3.11/site-packages/ansible
  ansible collection location = /home/labtesting/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/labtesting/venv/bin/ansible
  python version = 3.11.7 (main, Jan 18 2024, 16:08:57) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/home/labtesting/venv/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Configuration

Good Run

(venv) [labtesting@managementbackup ansible-project]$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /home/labtesting/.ansible.cfg
PARAMIKO_HOST_KEY_AUTO_ADD(/home/labtesting/.ansible.cfg) = True

CONNECTION:
==========

paramiko_ssh:
____________
host_key_auto_add(/home/labtesting/.ansible.cfg) = True

Bad Run

(venv) [labtesting@managementbackup ansible-project]$ ansible-config dump --only-changed -t all
CONFIG_FILE() = /home/labtesting/.ansible.cfg
PARAMIKO_HOST_KEY_AUTO_ADD(/home/labtesting/.ansible.cfg) = True

CONNECTION:
==========

paramiko_ssh:
____________
host_key_auto_add(/home/labtesting/.ansible.cfg) = True

OS / Environment

Steps to Reproduce

Playbook

- name: DEPLOY CISCO ROUTER UPDATE
  gather_facts: false
  # Hosts that are being targeted
  hosts: "{{ host_router_cisco }}"
  strategy: free

  tasks:
  - name: Check if selected bin file already exists
    ios_command:
      commands: "dir | inc {{ ios_filename }}"
    register: bin

  - name: Check register to see if the file already exists on router
    when: bin.stdout is not search('{{ ios_filename }}') or bin.stdout is not search('{{ ios_filesize }}')
    block:
      - name: Copy IOS image to router
        net_put: 
          src: "{{ ios_location }}/{{ ios_filename }}"
          dest: "flash:/{{ ios_filename }}"
        vars:
          ansible_command_timeout: 480

      - name: Find files with UUID filenames
        find:
          paths: "/usr/local/ansible-project/"
          patterns: "*-*-*-*-*"
        register: uuid_files

      - name: Delete files with UUID filenames
        file: 
          path: "{{ item.path }}"
          state: absent
        loop: "{{ uuid_files.files }}"

  - name: Set boot system image
    ios_command:
      commands:
        - "config terminal"
        - "no boot system"
        - "boot system flash:/{{ ios_filename }}"
        - "exit"

  - name: Write Memory
    cli_command:
      command: write memory
      prompt:
        - confirm
      answer:
        - y
###                                                                         ###
# We need to create a check to make sure the boot flash has changed correctly #
###                                                                         ###
  - name: Reload Router
    cli_command:
      command: reload
      prompt:
        - Save?
        - confirm
      answer:
        - y
        - y

  - name: Reset Connection since router is reloading
    meta: reset_connection

  - name: Waiting for router to reboot...
    wait_for_connection:
      delay: 10

Inventory

all:
  children:
    CISCO:
      children:
        CISCO_RTR:
          hosts:
            CISCO_RTR_TEST:
              ansible_host: 20.20.34.43
          vars:
            ansible_connection: network_cli
            ansible_network_os: cisco.ios.ios
            ansible_network_cli_ssh_type: paramiko

Extra Vars ('{"host_router_cisco":"CISCO_RTR_TEST","host_switch_cisco":null,"host_router_j":null,"host_switch_j":null,"ios_location":"/home/labtesting/Ansible/2951/c2951-universalk9-mz.SPA.155-3.M9","ios_filename":"c2951-universalk9-mz.SPA.155-3.M9.bin","ios_filesize":109728408}',)

Expected Results

I expected the playbook to not target the localhost aswell. Only the cisco router that the playbook calls for.

Actual Results

(venv) [labtesting@managementbackup ansible-project]$ python3 main.py 
No inventory folder to delete!
Please select host(s) to target: CISCO_RTR_TEST
Sucessfully created template
Please select an option: 
1  | Backup Configs
2  | Load Configs
3  | Update Systems
4  | Test
5  | Shutdown
6  | Version Info
7  | Change Target
8  | Exit
You selected: 3
Please provide the ios file to load: /home/labtesting/Ansible/2951/c2
951-universalk9-mz.SPA.155-3.M9/c2951-universalk9-mz.SPA.155-3.M9.bin

ansible-playbook [core 2.16.2]
  config file = /home/labtesting/.ansible.cfg
  configured module search path = ['/home/labtesting/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/labtesting/venv/lib/python3.11/site-packages/ansible
  ansible collection location = /home/labtesting/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/labtesting/venv/bin/ansible-playbook
  python version = 3.11.7 (main, Jan 18 2024, 16:08:57) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20)] (/home/labtesting/venv/bin/python3)
  jinja version = 3.1.2
  libyaml = True
Using /home/labtesting/.ansible.cfg as config file
setting up inventory plugins
Loading collection ansible.builtin from 
host_list declined parsing /home/labtesting/Ansible/ansible-project/groups/groups.yaml as it did not pass its verify_file() method
script declined parsing /home/labtesting/Ansible/ansible-project/groups/groups.yaml as it did not pass its verify_file() method
Parsed /home/labtesting/Ansible/ansible-project/groups/groups.yaml inventory source with yaml plugin
setting up inventory plugins
host_list declined parsing /home/labtesting/Ansible/ansible-project/groups/passwords.yaml as it did not pass its verify_file() method
script declined parsing /home/labtesting/Ansible/ansible-project/groups/passwords.yaml as it did not pass its verify_file() method
Parsed /home/labtesting/Ansible/ansible-project/groups/passwords.yaml inventory source with yaml plugin
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
Loading collection cisco.ios from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/cisco/ios
redirecting (type: action) ansible.builtin.net_put to ansible.netcommon.net_put
Loading collection ansible.netcommon from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/netcommon
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
Loading callback plugin default of type stdout, v2.0 from /home/labtesting/venv/lib/python3.11/site-packages/ansible/plugins/callback/default.py
Loading callback plugin awx_display of type stdout, v2.0 from /home/labtesting/venv/lib/python3.11/site-packages/ansible_runner/display_callback/callback/awx_display.py
Attempting to use 'awx_display' callback.
Skipping callback 'awx_display', as we already have a stdout callback.
Attempting to use 'default' callback.
Skipping callback 'default', as we already have a stdout callback.
Attempting to use 'junit' callback.
Attempting to use 'minimal' callback.
Skipping callback 'minimal', as we already have a stdout callback.
Attempting to use 'oneline' callback.
Skipping callback 'oneline', as we already have a stdout callback.
Attempting to use 'tree' callback.

PLAYBOOK: playUpdate.yaml ******************************************************
Positional arguments: playUpdate.yaml
verbosity: 5
connection: ssh
become_method: sudo
tags: ('all',)
inventory: ('/home/labtesting/Ansible/ansible-project/groups',)
extra_vars: ('{"host_router_cisco":"CISCO_RTR_TEST","host_switch_cisco":null,"host_router_j":null,"host_switch_j":null,"ios_location":"/home/labtesting/Ansible/2951/c2951-universalk9-mz.SPA.155-3.M9","ios_filename":"c2951-universalk9-mz.SPA.155-3.M9.bin","ios_filesize":109728408}',)
forks: 10
2 plays in playUpdate.yaml
[WARNING]: Could not match supplied host pattern, ignoring: None

PLAY [DEPLOY j UPDATE] ****************************************************
skipping: no hosts matched

PLAY [DEPLOY CISCO ROUTER UPDATE] **********************************************
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.utils from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/utils
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<20.20.34.43> Using network group action ios for ios_command
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<20.20.34.43> attempting to start connection
<20.20.34.43> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/labtesting/venv/bin/ansible-connection
<20.20.34.43> local domain socket does not exist, starting it
<20.20.34.43> control socket path is /home/labtesting/.ansible/pc/bc0058a548
<20.20.34.43> Loading collection ansible.builtin from 
<20.20.34.43> redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
<20.20.34.43> Loading collection ansible.netcommon from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/netcommon
<20.20.34.43> Loading collection ansible.utils from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/utils
<20.20.34.43> Loading collection cisco.ios from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/cisco/ios
<20.20.34.43> local domain socket listeners started successfully
<20.20.34.43> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os cisco.ios.ios
<20.20.34.43> ssh type is set to paramiko
<20.20.34.43> Loading collection ansible.builtin from 
<20.20.34.43> local domain socket path is /home/labtesting/.ansible/pc/bc0058a548
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: found ios_command  at /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/cisco/ios/plugins/modules/ios_command.py
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: running ios_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: complete
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: Result: {'changed': False, 'stdout': ['47  -rw-   108924928  Jan 19 2024 18:50:22 +00:00  c2951-universalk9-mz.SPA.155-3.M9.bin'], 'stdout_lines': [['47  -rw-   108924928  Jan 19 2024 18:50:22 +00:00  c2951-universalk9-mz.SPA.155-3.M9.bin']], 'invocation': {'module_args': {'commands': ['dir | inc c2951-universalk9-mz.SPA.155-3.M9.bin'], 'match': 'all', 'retries': 9, 'interval': 1, 'wait_for': None}}, '_ansible_parsed': True}

TASK [Check if selected bin file already exists] *******************************
task path: /home/labtesting/Ansible/ansible-project/playUpdate.yaml:28
ok: [CISCO_RTR_TEST] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "commands": [
                "dir | inc c2951-universalk9-mz.SPA.155-3.M9.bin"
            ],
            "interval": 1,
            "match": "all",
            "retries": 9,
            "wait_for": null
        }
    },
    "stdout": [
        "47  -rw-   108924928  Jan 19 2024 18:50:22 +00:00  c2951-universalk9-mz.SPA.155-3.M9.bin"
    ],
    "stdout_lines": [
        [
            "47  -rw-   108924928  Jan 19 2024 18:50:22 +00:00  c2951-universalk9-mz.SPA.155-3.M9.bin"
        ]
    ]
}
redirecting (type: action) ansible.builtin.net_put to ansible.netcommon.net_put
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.utils from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/utils
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
redirecting (type: modules) ansible.builtin.net_put to ansible.netcommon.net_put
redirecting (type: action) ansible.builtin.net_put to ansible.netcommon.net_put
redirecting (type: action) ansible.builtin.net_put to ansible.netcommon.net_put
<20.20.34.43> attempting to start connection
<20.20.34.43> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/labtesting/venv/bin/ansible-connection
<20.20.34.43> found existing local domain socket, using it!
<20.20.34.43> invoked shell using ssh_type: paramiko
<20.20.34.43> ssh connection done, setting terminal
<20.20.34.43> loaded terminal plugin for network_os cisco.ios.ios
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> firing event: on_become
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> firing event: on_open_shell()
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> ssh connection has completed successfully
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> updating play_context for connection
<20.20.34.43> Loading collection ansible.builtin from 
<20.20.34.43> local domain socket path is /home/labtesting/.ansible/pc/bc0058a548
redirecting (type: action) ansible.builtin.net_put to ansible.netcommon.net_put
Getting network OS from inventory

TASK [Copy IOS image to router] ************************************************
task path: /home/labtesting/Ansible/ansible-project/playUpdate.yaml:36
ok: [CISCO_RTR_TEST] => {
    "changed": false,
    "destination": "flash:/c2951-universalk9-mz.SPA.155-3.M9.bin",
    "msg": "Warning: 'utf-8' codec can't decode byte 0xc8 in position 19: invalid continuation byte idempotency check failed. Check dest"
}
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.utils from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/utils
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<20.20.34.43> attempting to start connection
<20.20.34.43> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/labtesting/venv/bin/ansible-connection
<20.20.34.43> found existing local domain socket, using it!
<20.20.34.43> updating play_context for connection
<20.20.34.43> Loading collection ansible.builtin from 
<20.20.34.43> local domain socket path is /home/labtesting/.ansible/pc/bc0058a548
<20.20.34.43> ESTABLISH LOCAL CONNECTION FOR USER: labtesting
<20.20.34.43> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949 `"&& mkdir "` echo /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693646.9711711-79868-242255861103871 `" && echo ansible-tmp-1705693646.9711711-79868-242255861103871="` echo /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693646.9711711-79868-242255861103871 `" ) && sleep 0'
Including module_utils file ansible/__init__.py
Including module_utils file ansible/module_utils/__init__.py
Including module_utils file ansible/module_utils/basic.py
Including module_utils file ansible/module_utils/_text.py
Including module_utils file ansible/module_utils/common/_json_compat.py
Including module_utils file ansible/module_utils/common/__init__.py
Including module_utils file ansible/module_utils/common/_utils.py
Including module_utils file ansible/module_utils/common/arg_spec.py
Including module_utils file ansible/module_utils/common/file.py
Including module_utils file ansible/module_utils/common/locale.py
Including module_utils file ansible/module_utils/common/parameters.py
Including module_utils file ansible/module_utils/common/collections.py
Including module_utils file ansible/module_utils/common/process.py
Including module_utils file ansible/module_utils/common/sys_info.py
Including module_utils file ansible/module_utils/common/text/converters.py
Including module_utils file ansible/module_utils/common/text/__init__.py
Including module_utils file ansible/module_utils/common/text/formatters.py
Including module_utils file ansible/module_utils/common/validation.py
Including module_utils file ansible/module_utils/common/warnings.py
Including module_utils file ansible/module_utils/compat/selectors.py
Including module_utils file ansible/module_utils/compat/__init__.py
Including module_utils file ansible/module_utils/compat/_selectors2.py
Including module_utils file ansible/module_utils/compat/selinux.py
Including module_utils file ansible/module_utils/distro/__init__.py
Including module_utils file ansible/module_utils/distro/_distro.py
Including module_utils file ansible/module_utils/errors.py
Including module_utils file ansible/module_utils/parsing/convert_bool.py
Including module_utils file ansible/module_utils/parsing/__init__.py
Including module_utils file ansible/module_utils/pycompat24.py
Including module_utils file ansible/module_utils/six/__init__.py
Using module file /home/labtesting/venv/lib/python3.11/site-packages/ansible/modules/find.py
<20.20.34.43> PUT /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/tmptfnk0ha1 TO /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693646.9711711-79868-242255861103871/AnsiballZ_find.py
<20.20.34.43> EXEC /bin/sh -c 'chmod u+x /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693646.9711711-79868-242255861103871/ /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693646.9711711-79868-242255861103871/AnsiballZ_find.py && sleep 0'
<20.20.34.43> EXEC /bin/sh -c '/home/labtesting/venv/bin/python3 /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693646.9711711-79868-242255861103871/AnsiballZ_find.py && sleep 0'
<20.20.34.43> EXEC /bin/sh -c 'rm -f -r /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693646.9711711-79868-242255861103871/ > /dev/null 2>&1 && sleep 0'

TASK [Find files with UUID filenames] ******************************************
task path: /home/labtesting/Ansible/ansible-project/playUpdate.yaml:43
[WARNING]: Skipped '/usr/local/ansible-project/' path due to this access issue:
'/usr/local/ansible-project/' is not a directory
ok: [CISCO_RTR_TEST] => {
    "changed": false,
    "examined": 0,
    "files": [],
    "invocation": {
        "module_args": {
            "age": null,
            "age_stamp": "mtime",
            "contains": null,
            "depth": null,
            "exact_mode": true,
            "excludes": null,
            "file_type": "file",
            "follow": false,
            "get_checksum": false,
            "hidden": false,
            "mode": null,
            "paths": [
                "/usr/local/ansible-project/"
            ],
            "patterns": [
                "*-*-*-*-*"
            ],
            "read_whole_file": false,
            "recurse": false,
            "size": null,
            "use_regex": false
        }
    },
    "matched": 0,
    "msg": "Not all paths examined, check warnings for details",
    "skipped_paths": {
        "/usr/local/ansible-project/": "'/usr/local/ansible-project/' is not a directory"
    }
}

TASK [Delete files with UUID filenames] ****************************************
task path: /home/labtesting/Ansible/ansible-project/playUpdate.yaml:49
skipping: [CISCO_RTR_TEST] => {
    "changed": false,
    "skipped_reason": "No items in the list"
}
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.utils from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/utils
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<20.20.34.43> Using network group action ios for ios_command
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<20.20.34.43> attempting to start connection
<20.20.34.43> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/labtesting/venv/bin/ansible-connection
<20.20.34.43> found existing local domain socket, using it!
<20.20.34.43> updating play_context for connection
<20.20.34.43> Loading collection ansible.builtin from 
<20.20.34.43> local domain socket path is /home/labtesting/.ansible/pc/bc0058a548
redirecting (type: action) ansible.builtin.ios to cisco.ios.ios
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
redirecting (type: modules) ansible.builtin.ios_command to cisco.ios.ios_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: found ios_command  at /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/cisco/ios/plugins/modules/ios_command.py
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: running ios_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: complete
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: Result: {'changed': False, 'stdout': ['Enter configuration commands, one per line.  End with CNTL/Z.', '', '', ''], 'stdout_lines': [['Enter configuration commands, one per line.  End with CNTL/Z.'], [''], [''], ['']], 'invocation': {'module_args': {'commands': ['config terminal', 'no boot system', 'boot system flash:/c2951-universalk9-mz.SPA.155-3.M9.bin', 'exit'], 'match': 'all', 'retries': 9, 'interval': 1, 'wait_for': None}}, '_ansible_parsed': True}

TASK [Set boot system image] ***************************************************
task path: /home/labtesting/Ansible/ansible-project/playUpdate.yaml:55
ok: [CISCO_RTR_TEST] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "commands": [
                "config terminal",
                "no boot system",
                "boot system flash:/c2951-universalk9-mz.SPA.155-3.M9.bin",
                "exit"
            ],
            "interval": 1,
            "match": "all",
            "retries": 9,
            "wait_for": null
        }
    },
    "stdout": [
        "Enter configuration commands, one per line.  End with CNTL/Z.",
        "",
        "",
        ""
    ],
    "stdout_lines": [
        [
            "Enter configuration commands, one per line.  End with CNTL/Z."
        ],
        [
            ""
        ],
        [
            ""
        ],
        [
            ""
        ]
    ]
}
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.utils from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/utils
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
redirecting (type: modules) ansible.builtin.cli_command to ansible.netcommon.cli_command
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
<20.20.34.43> attempting to start connection
<20.20.34.43> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/labtesting/venv/bin/ansible-connection
<20.20.34.43> found existing local domain socket, using it!
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> updating play_context for connection
<20.20.34.43> Loading collection ansible.builtin from 
<20.20.34.43> local domain socket path is /home/labtesting/.ansible/pc/bc0058a548
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
redirecting (type: modules) ansible.builtin.cli_command to ansible.netcommon.cli_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: found cli_command  at /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/netcommon/plugins/modules/cli_command.py
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: running cli_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: complete
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: Result: {'changed': False, 'stdout': 'Building configuration...\n[OK]', 'invocation': {'module_args': {'command': 'write memory', 'prompt': ['confirm'], 'answer': ['y'], 'newline': True, 'sendonly': False, 'check_all': False}}, '_ansible_parsed': True, 'stdout_lines': ['Building configuration...', '[OK]']}

TASK [Write Memory] ************************************************************
task path: /home/labtesting/Ansible/ansible-project/playUpdate.yaml:63
ok: [CISCO_RTR_TEST] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "answer": [
                "y"
            ],
            "check_all": false,
            "command": "write memory",
            "newline": true,
            "prompt": [
                "confirm"
            ],
            "sendonly": false
        }
    },
    "stdout": "Building configuration...\n[OK]",
    "stdout_lines": [
        "Building configuration...",
        "[OK]"
    ]
}
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.utils from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/utils
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
redirecting (type: modules) ansible.builtin.cli_command to ansible.netcommon.cli_command
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
<20.20.34.43> attempting to start connection
<20.20.34.43> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/labtesting/venv/bin/ansible-connection
<20.20.34.43> found existing local domain socket, using it!
<20.20.34.43> Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
<20.20.34.43> updating play_context for connection
<20.20.34.43> Loading collection ansible.builtin from 
<20.20.34.43> local domain socket path is /home/labtesting/.ansible/pc/bc0058a548
redirecting (type: action) ansible.builtin.cli_command to ansible.netcommon.cli_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
redirecting (type: modules) ansible.builtin.cli_command to ansible.netcommon.cli_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: found cli_command  at /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/netcommon/plugins/modules/cli_command.py
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: running cli_command
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: complete
<20.20.34.43> ANSIBLE_NETWORK_IMPORT_MODULES: Result: {'changed': False, 'stdout': 'None', 'invocation': {'module_args': {'command': 'reload', 'prompt': ['Save?', 'confirm'], 'answer': ['y', 'y'], 'newline': True, 'sendonly': False, 'check_all': False}}, '_ansible_parsed': True, 'stdout_lines': ['None']}

TASK [Reload Router] ***********************************************************
task path: /home/labtesting/Ansible/ansible-project/playUpdate.yaml:73
ok: [CISCO_RTR_TEST] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "answer": [
                "y",
                "y"
            ],
            "check_all": false,
            "command": "reload",
            "newline": true,
            "prompt": [
                "Save?",
                "confirm"
            ],
            "sendonly": false
        }
    },
    "stdout": "None",
    "stdout_lines": [
        "None"
    ]
}
META: reset connection
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
Loading collection ansible.utils from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/utils
redirecting (type: become) ansible.builtin.enable to ansible.netcommon.enable
<20.20.34.43> attempting to start connection
<20.20.34.43> using connection plugin ansible.netcommon.network_cli
Found ansible-connection at path /home/labtesting/venv/bin/ansible-connection
<20.20.34.43> local domain socket does not exist, starting it
<20.20.34.43> control socket path is /home/labtesting/.ansible/pc/bc0058a548
<20.20.34.43> Loading collection ansible.builtin from 
<20.20.34.43> redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
<20.20.34.43> Loading collection ansible.netcommon from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/netcommon
<20.20.34.43> Loading collection ansible.utils from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/ansible/utils
<20.20.34.43> Loading collection cisco.ios from /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/cisco/ios
<20.20.34.43> local domain socket listeners started successfully
<20.20.34.43> loaded cliconf plugin ansible_collections.cisco.ios.plugins.cliconf.ios from path /home/labtesting/venv/lib/python3.11/site-packages/ansible_collections/cisco/ios/plugins/cliconf/ios.py for network_os cisco.ios.ios
<20.20.34.43> ssh type is set to paramiko
<20.20.34.43> Loading collection ansible.builtin from 
<20.20.34.43> local domain socket path is /home/labtesting/.ansible/pc/bc0058a548
[DEPRECATION WARNING]: PlayContext.verbosity is deprecated, use 
ansible.utils.display.Display.verbosity instead. This feature will be removed 
in version 2.18. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
<20.20.34.43> ESTABLISH PARAMIKO SSH CONNECTION FOR USER: changemeL15user on PORT 22 TO 20.20.34.43
wait_for_connection: attempting ping module test
<20.20.34.43> ESTABLISH LOCAL CONNECTION FOR USER: labtesting
<20.20.34.43> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949 `"&& mkdir "` echo /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693901.056327-79907-82925840613979 `" && echo ansible-tmp-1705693901.056327-79907-82925840613979="` echo /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693901.056327-79907-82925840613979 `" ) && sleep 0'
Including module_utils file ansible/__init__.py
Including module_utils file ansible/module_utils/__init__.py
Including module_utils file ansible/module_utils/basic.py
Including module_utils file ansible/module_utils/_text.py
Including module_utils file ansible/module_utils/common/_json_compat.py
Including module_utils file ansible/module_utils/common/__init__.py
Including module_utils file ansible/module_utils/common/_utils.py
Including module_utils file ansible/module_utils/common/arg_spec.py
Including module_utils file ansible/module_utils/common/file.py
Including module_utils file ansible/module_utils/common/locale.py
Including module_utils file ansible/module_utils/common/parameters.py
Including module_utils file ansible/module_utils/common/collections.py
Including module_utils file ansible/module_utils/common/process.py
Including module_utils file ansible/module_utils/common/sys_info.py
Including module_utils file ansible/module_utils/common/text/converters.py
Including module_utils file ansible/module_utils/common/text/__init__.py
Including module_utils file ansible/module_utils/common/text/formatters.py
Including module_utils file ansible/module_utils/common/validation.py
Including module_utils file ansible/module_utils/common/warnings.py
Including module_utils file ansible/module_utils/compat/selectors.py
Including module_utils file ansible/module_utils/compat/__init__.py
Including module_utils file ansible/module_utils/compat/_selectors2.py
Including module_utils file ansible/module_utils/compat/selinux.py
Including module_utils file ansible/module_utils/distro/__init__.py
Including module_utils file ansible/module_utils/distro/_distro.py
Including module_utils file ansible/module_utils/errors.py
Including module_utils file ansible/module_utils/parsing/convert_bool.py
Including module_utils file ansible/module_utils/parsing/__init__.py
Including module_utils file ansible/module_utils/pycompat24.py
Including module_utils file ansible/module_utils/six/__init__.py
Using module file /home/labtesting/venv/lib/python3.11/site-packages/ansible/modules/ping.py
<20.20.34.43> PUT /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/tmpo_3a3m6p TO /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693901.056327-79907-82925840613979/AnsiballZ_ping.py
<20.20.34.43> EXEC /bin/sh -c 'chmod u+x /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693901.056327-79907-82925840613979/ /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693901.056327-79907-82925840613979/AnsiballZ_ping.py && sleep 0'
<20.20.34.43> EXEC /bin/sh -c '/home/labtesting/venv/bin/python3 /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693901.056327-79907-82925840613979/AnsiballZ_ping.py && sleep 0'
<20.20.34.43> EXEC /bin/sh -c 'rm -f -r /home/labtesting/.ansible/tmp/ansible-local-79791p_vzw949/ansible-tmp-1705693901.056327-79907-82925840613979/ > /dev/null 2>&1 && sleep 0'

TASK [Waiting for router to reboot...] *****************************************
task path: /home/labtesting/Ansible/ansible-project/playUpdate.yaml:86
ok: [CISCO_RTR_TEST] => {
    "changed": false,
    "elapsed": 243
}

PLAY RECAP *********************************************************************
CISCO_RTR_TEST : ok=7    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

(venv) [labtesting@managementbackup ansible-project]$ ls -l
total 107088
drwxrwxr-x. 3 labtesting labtesting        50 Jan 19 14:41 artifacts
-rw-r--r--. 1 labtesting labtesting 109592576 Jan 19 14:43 d5bd909b-e6f2-4bd0-a1e6-7c9f19528082
drwxr-xr-x. 2 labtesting labtesting        47 Jan 19 14:21 groups
-rw-r--r--. 1 labtesting labtesting      5209 Jan 18 16:36 main.py
-rw-r--r--. 1 labtesting labtesting     10743 Jan 18 16:36 playBackup.yaml
-rw-r--r--. 1 labtesting labtesting      2359 Jan 18 16:36 playLoadConfig.yaml
-rw-r--r--. 1 labtesting labtesting       882 Jan 18 16:36 playShutdown.yaml
-rw-r--r--. 1 labtesting labtesting      2005 Jan 18 17:11 playUpdate.orig
-rw-r--r--. 1 labtesting labtesting      2477 Jan 18 17:13 playUpdate.yaml
-rw-r--r--. 1 labtesting labtesting      1878 Jan 18 16:36 playVersion.yaml
drwxr-xr-x. 2 labtesting labtesting        33 Jan 18 16:39 __pycache__
-rw-r--r--. 1 labtesting labtesting     21315 Jan 18 16:36 SP5.py

Code of Conduct

Akasurde commented 10 months ago

cc @ryandyf

ryandyf commented 10 months ago

@Akasurde Thank you for transferring this over. The reason why I had made the ticket in core was because the issue also occurred with the ansible.builtin.copy module, though to be fair, the behavior was slightly different but the issue at hand was the same.

ryandyf commented 10 months ago

Hey Netcommon Team, Sivel over that the core team found the cause of this bug. Attaching reply here, referencing: https://github.com/ansible/ansible/issues/82572#issuecomment-1906778882

Alright, with that information, I've been able to dig into this more and determine that the issue is indeed with the net_put action plugin from ansible.netcommon.

First, I'll copy one of the important sections from the original output:

ok: [CISCO_RTR_TEST] => {
    "changed": false,
    "destination": "flash:/c2951-universalk9-mz.SPA.155-3.M9.bin",
    "msg": "Warning: 'utf-8' codec can't decode byte 0xc8 in position 19: invalid continuation byte idempotency check failed. Check dest"
}

That msg is the key here to tracing this further. When that msg is displayed, it is because the call to _handle_existing_file raised an exception.

The issue is within _handle_existing_file, due to the fact that the remote file is downloaded to a uuid4 named temp file in the cwd, and then is opened in text mode, and not binary mode. Opening and reading in text mode results in a UnicodeDecodeError that is not caught by the plugin, and thus never removes the temp file that was meant to be used for checksum comparison.

https://github.com/ansible-collections/ansible.netcommon/blob/257b77eaff85f1ef7c76a0b4dc8779f70a5f8bd5/plugins/action/net_put.py#L135-L178

There are probably a couple of changes that need to be made to net_put to operate more smoothly:

  1. Open the files with rb instead of r
  2. Remove the call to to_bytes, as the contents are already bytes after (1)
  3. Expand the try/except to just except Exception: instead of only (IOError, OSError)

In any case, this information will be needed over at ansible-collections/ansible.netcommon#617 in order to get this resolved.

The silent transition to running copy locally would also need resolved in netcommon.

ryandyf commented 10 months ago

@KB-perByte Hey, is there any update to this? Thanks!