I'm new to the Ansible world, so I'll do my best to explain everything. If I leave something out or need to clarify, just let me know.
So, I've been working on upgrades for various Cisco switches/routers, and the 3850s running IOS-XE 16.x are causing me a slight issue. Basically, I want to run the command request platform software package clean switch all file flash:
which will result in a prompt that says Do you want to proceed? [y/n]
to which you simply enter "y" without the need for a CR.
It's important to note that if you were just copying/pasting configuration from a txt file, you could not paste in the "y" and you would manually need to enter it in. Doing so prevents the prompt from appearing (you can interact with the console while you wait 15-45 seconds for the output).
My Ansible code is waiting for the prompt, but when I run in -vvvv I do not see the output of the command and it ultimately times out. If I change the prompt to '[confirm]' and the response to "\r" I do see the output, but the cleanup is not taken (I can confirm because there would be more output and I can manually check after the fact).
I thought the prompt parameter would wait until the prompt occurs, but I'm guessing not? How does this actually work? It has not been a problem before because the prompts are generally instant. In this case, there's a delay every time.
Here's my code:
- name: CLEAN UP OLD SOFTWARE
ios_command:
commands:
- command: "request platform software package clean switch all file flash:"
prompt: Do you want to proceed? \[y/n\]
answer: "y"
vars:
ansible_command_timeout: 90
when: compliant_ios_version == ansible_net_version
This is the result:
WARNING: The below traceback may *not* be related to the actual failure.
File "/tmp/ansible_ios_command_payload_XyRXx3/ansible_ios_command_payload.zip/ansible/module_utils/network/ios/ios.py", line 145, in run_commands
return connection.run_commands(commands=commands, check_rc=check_rc)
File "/tmp/ansible_ios_command_payload_XyRXx3/ansible_ios_command_payload.zip/ansible/module_utils/connection.py", line 182, in __rpc__
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [SWITCH1]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"auth_pass": null,
"authorize": null,
"commands": [
{
"answer": "y",
"command": "request platform software package clean switch all file flash:",
"prompt": "Do you want to proceed? \\[y/n\\]"
}
],
"host": null,
"interval": 1,
"match": "all",
"password": null,
"port": null,
"provider": null,
"retries": 10,
"ssh_keyfile": null,
"timeout": null,
"username": null,
"wait_for": null
}
},
"msg": "command timeout triggered, timeout value is 40 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."
}
to retry, use: --limit @/opt/ansible/Test_Clean.retry
PLAY RECAP *************************************************************************************************************************
SWITCH1 : ok=0 changed=0 unreachable=0 failed=1
Playbook run took 0 days, 0 hours, 0 minutes, 92 seconds
Here's what would be displayed on the switch console:
SWITCH1# request platform software package clean switch all file flash:
This operation may take several minutes...
Running command on switch 1
Cleaning up unnecessary package files
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
packages.conf
File is in use, will not delete.
cat3k_caa-guestshell.16.06.06.SPA.pkg
File is in use, will not delete.
cat3k_caa-rpbase.16.06.06.SPA.pkg
File is in use, will not delete.
cat3k_caa-rpcore.16.06.06.SPA.pkg
File is in use, will not delete.
cat3k_caa-srdriver.16.06.06.SPA.pkg
File is in use, will not delete.
cat3k_caa-webui.16.06.06.SPA.pkg
File is in use, will not delete.
done.
Running command on switch 2
Cleaning up unnecessary package files
Scanning boot directory for packages ... done.
Preparing packages list to delete ...
cat3k_caa-rpbase.16.06.06.SPA.pkg
File is in use, will not delete.
packages.conf
File is in use, will not delete.
cat3k_caa-guestshell.16.06.06.SPA.pkg
File is in use, will not delete.
cat3k_caa-rpcore.16.06.06.SPA.pkg
File is in use, will not delete.
cat3k_caa-srdriver.16.06.06.SPA.pkg
File is in use, will not delete.
cat3k_caa-webui.16.06.06.SPA.pkg
File is in use, will not delete.
done.
The following files will be deleted:
[switch 1]:
/flash/cat3k_caa-guestshell.16.06.05.SPA.pkg
/flash/cat3k_caa-rpbase.16.06.05.SPA.pkg
/flash/cat3k_caa-rpcore.16.06.05.SPA.pkg
/flash/cat3k_caa-srdriver.16.06.05.SPA.pkg
/flash/cat3k_caa-universalk9.16.06.06.SPA.conf
/flash/cat3k_caa-webui.16.06.05.SPA.pkg
/flash/packages.conf.00-
[switch 2]:
/flash/cat3k_caa-guestshell.16.06.05.SPA.pkg
/flash/cat3k_caa-rpbase.16.06.05.SPA.pkg
/flash/cat3k_caa-rpcore.16.06.05.SPA.pkg
/flash/cat3k_caa-srdriver.16.06.05.SPA.pkg
/flash/cat3k_caa-universalk9.16.06.06.SPA.conf
/flash/cat3k_caa-webui.16.06.05.SPA.pkg
/flash/packages.conf.00-
Do you want to proceed? [y/n]
I've searched around a lot and tried everything I could think of. I have not seen anyone come across this specific issue yet. Any ideas?
I'd appreciate any help. I'm pretty much dead in the water at this point.