# Multi prompt issue with cisco.ios.ios\_command

**URL:** <https://forum.ansible.com/t/multi-prompt-issue-with-cisco-ios-ios-command/38664>\
**Category:** Ansible Project\
**Created:** [January 25, 2024, 9:09pm UTC](https://forum.ansible.com/t/multi-prompt-issue-with-cisco-ios-ios-command/38664 "2024-01-25T21:09:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bikram](https://avatars.discourse-cdn.com/v4/letter/b/f04885/32.png) [@Bikram](https://forum.ansible.com/u/Bikram)\
**Post date:** [January 25, 2024, 9:09pm UTC](https://forum.ansible.com/t/multi-prompt-issue-with-cisco-ios-ios-command/38664/1 "2024-01-25T21:09:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dbs34](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@dbs34](https://forum.ansible.com/u/dbs34)\
**Post date:** [January 26, 2024, 4:51pm UTC](https://forum.ansible.com/t/multi-prompt-issue-with-cisco-ios-ios-command/38664/2 "2024-01-26T16:51:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bikram](https://avatars.discourse-cdn.com/v4/letter/b/f04885/32.png) [@Bikram](https://forum.ansible.com/u/Bikram)\
**Post date:** [January 26, 2024, 8:59pm UTC](https://forum.ansible.com/t/multi-prompt-issue-with-cisco-ios-ios-command/38664/3 "2024-01-26T20:59:37Z")

</div>

Hi Smith,

Thanks for your suggestions but unfortunately, it’s a single command and we cannot split it.  
I am planning to use the ‘ansible.netcommon.cli\_command’ module instead which has an option to check all conditions and I’m going to test it soon.

I find this module more effective than the ios\_command module

**- name: Install and activate new IOS image**

**ansible.netcommon.cli\_command:**

**command: ‘install add file {{ fsystem }}:{{ image\_9300.image\_name }} activate commit’**

**check\_all: true**

**prompt:**

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

**- ‘Do you want to proceed? [y/n]’**

**answer:**

**- ‘y’**

**- ‘y’**

**vars:**

**ansible\_command\_timeout: 14400**

-Bikram
