You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using Ansible to execute a command on a Cisco IOS-XR router. The command initiates a software upgrade. When the "synchronous" key word is added to the command, the command prompt will not return until the operation is complete. The router will periodically update the status of the upgrade and will finally return the command prompt when complete (often resulting in a reload).
The Ansible task is using wait_for and looking at the result[0[ output to find completed without error. However, this does not work and it hangs util the timeout is reached (1800 seconds).
This initiates the software upgrade and the script will wait for up to 1800 seconds before timing out.
It should stop when it detects the string "completed without error".
However, it always times out.
If you following the upgrade directly on the router (mirroring what Ansible would be seeing), you can see it completes and the completed without error string is received.
1/13/2025 4:45 PM •
RP/0/RP0/CPU0:c8k-1#install attach
Mon Jan 13 21:41:17.796 UTC
Attached to:
install replace /harddisk:/8000-x64-7.11.1.iso reload commit
Transaction 3
Press Ctrl-C to return to the exec prompt. This will not cancel the install operation
Current activity: Verify input and download ISO ...
Current activity: Extract main ISO contents to internal repository if needed .......
Current activity: Veto check .
Current activity: Package add or other package operation
Current activity: Apply by reload
Transaction 3: Pre-reload steps completed without error, reloading
.
Connection to 172.26.228.240 closed.
It seems the wait_for is not working.
Note: The timeout is set for 1800 seconds (30 minutes), but this task usually takes less than 10 minutes on the router.
EXPECTED RESULTS
Expect the Ansible task to complete when the software upgrade is applied and the completed without error string is received.
ACTUAL RESULTS
The task simply times out.
1/13/2025 5:14 PM •
Perform task: TASK: Running CLI install image (N)o/(y)es/(c)ontinue: **********************************************************************
TASK [Running CLI install image] **********************************************************************************************************
task path: /home/vxr/ansible-xr-upgrade/playbook.yml:165
redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli
redirecting (type: modules) ansible.builtin.iosxr_command to cisco.iosxr.iosxr_command
redirecting (type: action) ansible.builtin.iosxr to cisco.iosxr.iosxr
redirecting (type: action) ansible.builtin.iosxr to cisco.iosxr.iosxr
redirecting (type: action) ansible.builtin.iosxr to cisco.iosxr.iosxr
redirecting (type: modules) ansible.builtin.iosxr_command to cisco.iosxr.iosxr_command
The full traceback is:
File "/home/vxr/xrupgrade_venv/lib/python3.10/site-packages/ansible_collections/cisco/iosxr/plugins/module_utils/network/iosxr/iosxr.py", line 492, in run_commands
return connection.run_commands(commands=commands, check_rc=check_rc)
File "/home/vxr/xrupgrade_venv/lib/python3.10/site-packages/ansible/module_utils/connection.py", line 199, in __rpc__
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [c8k-1]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"commands": [
{
"command": "install replace /harddisk:/8000-x64-7.11.1.iso noprompt reload commit synchronous"
}
],
"interval": 1,
"match": "all",
"retries": 10,
"wait_for": [
"result[0] contains Apply by reload"
]
}
},
"msg": "command timeout triggered, timeout value is 1800 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."
}
PLAY RECAP ********************************************************************************************************************************
c8k-1 : ok=2 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
The text was updated successfully, but these errors were encountered:
SUMMARY
I'm using Ansible to execute a command on a Cisco IOS-XR router. The command initiates a software upgrade. When the "synchronous" key word is added to the command, the command prompt will not return until the operation is complete. The router will periodically update the status of the upgrade and will finally return the command prompt when complete (often resulting in a reload).
The Ansible task is using
wait_for
and looking at theresult[0[
output to findcompleted without error
. However, this does not work and it hangs util the timeout is reached (1800 seconds).ISSUE TYPE
COMPONENT NAME
iosxr_command
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Ubuntu 22.04.4 LTS running as VM in VMware host
STEPS TO REPRODUCE
The Ansible task is:
This initiates the software upgrade and the script will wait for up to 1800 seconds before timing out.
It should stop when it detects the string "completed without error".
However, it always times out.
If you following the upgrade directly on the router (mirroring what Ansible would be seeing), you can see it completes and the
completed without error
string is received.It seems the
wait_for
is not working.Note: The timeout is set for 1800 seconds (30 minutes), but this task usually takes less than 10 minutes on the router.
EXPECTED RESULTS
Expect the Ansible task to complete when the software upgrade is applied and the
completed without error
string is received.ACTUAL RESULTS
The task simply times out.
The text was updated successfully, but these errors were encountered: