I am trying to automate the process of upgrading IOS on Cisco devices.
Everything seems to be working fine until the process of copying the file begins.
The issue I am encountering is that ansible keeps sending data (I assume it keeps sending the same file a couple of times in a stream) to the IOS device.
I noticed this issue when I logged in to one of the switches to which I am trying to upgrade and saw how the file keeps growing and growing, to up to four times its size (i.e. filesize is ~ 21k but it was growing already on th 80k+).
Process ends when the “timeout” time is reached. Subsequently, the file gets deleted from the switch, as the switches interprets that the file transfer was interrupted.
Here is y core. Any help will be much appreciated:
I also tried many times with sftp or scp with ios_command module but no luck. Instead, as shown below, net_put successfully copied the file over to the Cisco switch. The ansible_ssh_user and ansible_ssh_pass needs to be set in inventory file.
One issue I’m facing with the net_put module is that next task using ios_command after the copying fails to be executed. It gave error message “ConnectionError(to_text(msg, errors=‘surrogate_then_replace’), code=code)”.
name: Copy over ios image
net_put:
src: “{{ nm_sw_image_file }}” # Need ansible_ssh_user and ansible_ssh_pass set up.
vars:
ansible_command_timeout: 3600 # default time out is 30 sec. Image copy takes about 30 min