How to write script for multiple prompts?

Hi,

Below is the command i need executed as part of IOS upgrade activiity. As you can see, it involves 2 prompts. So how do i write a script using ios_command module when multiple prompts are involved?

install add file flash:cat9k_lite_iosxe.16.12.01.SPA.bin activate commit

This operation requires a reload of the system. Do you want to proceed?

Please confirm you have changed boot config to flash:packages.conf [y/n]y

— Starting initial file syncing —

This operation requires a reload of the system. Do you want to proceed? [y/n]y

Will the below script work?

ios_command:

commands:

command: install add file flash:cat9k_lite_iosxe.16.12.01.SPA.bin activate commit

prompt: ‘Do you want to proceed?’

answer: ‘y’

prompt: ‘Do you want to proceed?’

answer: ‘y’

Hi,

I end up using shell scripts for these ios interaction. ios_command and other modules are not handling in a right way the timeouts:
For some new ios version this command in one shot and without interaction could be useful:
install add file flash:cat9k_lite_iosxe.16.12.04.SPA.bin activate commit prompt-level none
For old ios versions i created shell script for prompting also: