Hi Bikram, 

You could try splitting the tasks into two seperate tasks and adding a 
pause.  see below.

- name: Install new IOS image hosts: cisco_switches tasks: - name: Add IOS 
image ios_command: commands: - command: install add file 
flash:cat9k_iosxe.17.09.04a.SPA.bin 
activate commit prompt: - 'Please confirm you have changed boot config to 
flash:packages.conf [y/n]' answer: - y register: add_result - name: Confirm 
flash boot config pause: seconds: 15 when: add_result is succeeded - name: 
Activate IOS image ios_command: commands: - '' prompt: - 'This operation 
requires a reload of the system. Do you want to proceed? [y/n]' answer: - y 
when: add_result is succeeded 
On Thursday, January 25, 2024 at 4:10:02 PM UTC-5 Bikram wrote:

> Hi Team,
>
> I am trying to upgrade a cat9300 switch from version 16.06.06 to 
> 17.09.04a. The switch is in bundle mode and will convert it to install mode 
> as well.
>
> Here is my task:
>
> - name: Install and activate new IOS image
>
>   cisco.ios.ios_command:
>
>       commands:
>
>         - command: 'install add file flash: 
> cat9k_iosxe.17.09.04a.SPA.bin   activate commit'
>
>           prompt:
>
>              - 'Please confirm you have changed boot config to 
> flash:packages.conf \[y/n\]'
>
>              - 'This operation requires a reload of the system. Do you 
> want to proceed\? \[y/n\]'
>
>           answer:
>
>              - 'y'
>
>              - 'y'
>
>   register: install_image
>
>   vars:
>
>       ansible_command_timeout: 1400
>
>
> Problem is dealing with multi prompt (with some delay between prompts). My 
> task can catch the first prompt and answer accordingly but failed to catch 
> the second prompt.
>
>
> Here is the actual output when I upgrade the switch manually:
>
> XX-9300#install add file flash:cat9k_iosxe.17.09.04a.SPA.bin activate 
> commit
> install_add_activate_commit: START Sat Jan 20 04:36:32 UTC 2024
> install_add_activate_commit: Adding PACKAGE
>
>  
>
> 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 ---
> [1]: Copying flash:cat9k_iosxe.17.09.04a.SPA.bin from switch 1 to switch 2
> Finished initial file syncing
>
> --- Starting Add ---
> --- cut off some text----
> Finished Add
>
> install_add_activate_commit: Activating PACKAGE
> Following packages shall be activated:
> /flash/cat9k-wlc.17.09.04a.SPA.pkg
> ---cut off some text--
>
> *This operation requires a reload of the system. Do you want to proceed? 
> [y/n]y*
> --- Starting Activate ---
> Performing Activate on all members
>   [1] Activate package(s) on switch 1
>
>
> Any help is much appreciated.
>
>
> Thanks
>
> Bikram
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/60d09529-517d-4e00-abb7-2b5e27031754n%40googlegroups.com.

Reply via email to