# IOS upgrade on cisco c9200 switch to install mode with cisco.ios.ios\_command

**URL:** <https://forum.ansible.com/t/ios-upgrade-on-cisco-c9200-switch-to-install-mode-with-cisco-ios-ios-command/41015>\
**Category:** Get Help\
**Created:** [March 13, 2025, 8:46am UTC](https://forum.ansible.com/t/ios-upgrade-on-cisco-c9200-switch-to-install-mode-with-cisco-ios-ios-command/41015 "2025-03-13T08:46:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukas\_Dermisek](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lukas_dermisek/32/7863_2.png) [@Lukas\_Dermisek](https://forum.ansible.com/u/Lukas_Dermisek)\
**Post date:** [March 13, 2025, 8:46am UTC](https://forum.ansible.com/t/ios-upgrade-on-cisco-c9200-switch-to-install-mode-with-cisco-ios-ios-command/41015/1 "2025-03-13T08:46:32Z")

</div>

Hello,  
I have issue with this task in my playbook:

- name: Install and Reload Switch  
cisco.ios.ios\_command:  
commands:  
- command: install add file flash:cat9k\_lite\_iosxe.17.09.06a.SPA.bin activate commit  
prompt: This operation requires a reload of the system. Do you want to proceed?  
answer: ‘y’  
register: inrel\_output  
vars:  
ansible\_command\_timeout: 1450

but i can see in debug msg  
“stdout\_lines”: [  
[  
“install\_add\_activate\_commit: START Thu Mar 13 10:31:19 met 2025”,  
“install\_add: Adding IMG”,  
“— Starting initial file syncing —”,  
“Copying flash:cat9k\_lite\_iosxe.17.09.06a.SPA.bin from Switch 1 to Switch 1 2”,  
“Info: Finished copying to the selected Switch”,  
“Finished initial file syncing”,  
“”,  
“— Starting Add —”,  
“Performing Add on all members”,  
" [1] Finished Add package(s) on Switch 1",  
" [2] Finished Add package(s) on Switch 2",  
“Checking status of Add on [1 2]”,  
“Add: Passed on [1 2]”,  
“Finished Add”,  
“”,  
“Image added. Version: 17.09.06a.0.12”,  
“”,  
“install\_activate: Activating IMG”,  
“Following packages shall be activated:”,  
“/flash/cat9k\_lite-rpbase.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-rpboot.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-srdriver.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-webui.17.09.06a.SPA.pkg”,  
“Following packages shall be activated:”,  
“/flash/cat9k\_lite-rpbase.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-rpboot.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-srdriver.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-webui.17.09.06a.SPA.pkg”,  
“”,  
“This operation may require a reload of the system. Do you want to proceed? [y/n]No User Response, Request Timeout”  
]  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![iwt-cmd](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iwt-cmd/32/9120_2.png) [@iwt-cmd](https://forum.ansible.com/u/iwt-cmd)\
**Post date:** [March 13, 2025, 1:13pm UTC](https://forum.ansible.com/t/ios-upgrade-on-cisco-c9200-switch-to-install-mode-with-cisco-ios-ios-command/41015/2 "2025-03-13T13:13:41Z")

</div>

Hi @Lukas_Dermisek, welcome to the Ansible Forum!

I don’t have much firsthand experience using the Cisco IOS module but I have a couple of suggestions based on the documentation example:

- The prompt wording looks different between what you have and the debug message  
Playbook: “This operation requires a reload of the system. Do you want to proceed?”  
Debug: “This operation may require a reload of the system. Do you want to proceed? [y/n]”
- You will probably need to escape the square brackets in “[y/n]”
- The prompt will probably need to be enclosed with single quotes

```auto
- name: Run commands that require answering a prompt
  cisco.ios.ios_command:
    commands:
      - command: "clear counters GigabitEthernet2"
        prompt: 'Clear "show interface" counters on this interface \[confirm\]'
        answer: "y"
      - command: "clear counters GigabitEthernet3"
        prompt: "[confirm]"
        answer: "\r"

```

[cisco.ios.ios\_command module – Module to run commands on remote devices. — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/collections/cisco/ios/ios_command_module.html#ansible-collections-cisco-ios-ios-command-module)

Again, that’s a first pass based on the documentation. If someone with more working knowledge of the IOS module has a different take on it, I’ll definitely differ to them.

Best regards,

Joe

---

<div class="post-metadata">

**Author:** ![Lukas\_Dermisek](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lukas_dermisek/32/7863_2.png) [@Lukas\_Dermisek](https://forum.ansible.com/u/Lukas_Dermisek)\
**Post date:** [March 13, 2025, 1:55pm UTC](https://forum.ansible.com/t/ios-upgrade-on-cisco-c9200-switch-to-install-mode-with-cisco-ios-ios-command/41015/3 "2025-03-13T13:55:40Z")

</div>

Hello,  
Thanks for check, i have change ansible task base on your comments, but unfortunately same result as before:  
-playbook task:  
- name: Install and Reload Switch  
cisco.ios.ios\_command:  
commands:  
- command: “install add file flash:cat9k\_lite\_iosxe.17.09.06a.SPA.bin activate commit”  
prompt: ‘This operation may require a reload of the system. Do you want to proceed? [y/n]’  
answer: “y”  
register: inrel\_output  
vars:  
ansible\_command\_timeout: 1450

-debug output:  
],  
“stdout\_lines”: [  
[  
“install\_add\_activate\_commit: START Thu Mar 13 15:43:47 met 2025”,  
“install\_add: Adding IMG”,  
“— Starting initial file syncing —”,  
“Copying flash:cat9k\_lite\_iosxe.17.09.06a.SPA.bin from Switch 1 to Switch 1 2”,  
“Info: Finished copying to the selected Switch”,  
“Finished initial file syncing”,  
“”,  
“— Starting Add —”,  
“Performing Add on all members”,  
" [1] Finished Add package(s) on Switch 1",  
" [2] Finished Add package(s) on Switch 2",  
“Checking status of Add on [1 2]”,  
“Add: Passed on [1 2]”,  
“Finished Add”,  
“”,  
“Image added. Version: 17.09.06a.0.12”,  
“”,  
“install\_activate: Activating IMG”,  
“Following packages shall be activated:”,  
“/flash/cat9k\_lite-rpbase.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-rpboot.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-srdriver.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-webui.17.09.06a.SPA.pkg”,  
“Following packages shall be activated:”,  
“/flash/cat9k\_lite-rpbase.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-rpboot.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-srdriver.17.09.06a.SPA.pkg”,  
“/flash/cat9k\_lite-webui.17.09.06a.SPA.pkg”,  
“”,  
“This operation may require a reload of the system. Do you want to proceed? [y/n]No User Response, Request Timeout”  
]  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![Lukas\_Dermisek](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lukas_dermisek/32/7863_2.png) [@Lukas\_Dermisek](https://forum.ansible.com/u/Lukas_Dermisek)\
**Post date:** [March 13, 2025, 2:26pm UTC](https://forum.ansible.com/t/ios-upgrade-on-cisco-c9200-switch-to-install-mode-with-cisco-ios-ios-command/41015/4 "2025-03-13T14:26:52Z")

</div>

I have completely removed [y/n] from the prompt and task completed succesfully. Many thanks Joe

playbook:

- name: Install and Reload Switch  
cisco.ios.ios\_command:  
commands:  
- command: “install add file flash:cat9k\_lite\_iosxe.17.09.06a.SPA.bin activate commit”  
prompt: ‘This operation may require a reload of the system. Do you want to proceed?’  
answer: “y”  
register: inrel\_output  
vars:  
ansible\_command\_timeout: 1450

and i can see it in debug:  
“This operation may require a reload of the system. Do you want to proceed? [y/n]y”,  
“”,

---

<div class="post-metadata">

**Author:** ![Datadog](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@Datadog](https://forum.ansible.com/u/Datadog)\
**Post date:** [November 19, 2025, 5:42am UTC](https://forum.ansible.com/t/ios-upgrade-on-cisco-c9200-switch-to-install-mode-with-cisco-ios-ios-command/41015/5 "2025-11-19T05:42:57Z")

</div>

I know this is old, but you could also “prompt-level none” and it won’t ask.

---

<div class="post-metadata">

**Author:** ![Lukas\_Dermisek](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/lukas_dermisek/32/7863_2.png) [@Lukas\_Dermisek](https://forum.ansible.com/u/Lukas_Dermisek)\
**Post date:** [November 19, 2025, 6:32am UTC](https://forum.ansible.com/t/ios-upgrade-on-cisco-c9200-switch-to-install-mode-with-cisco-ios-ios-command/41015/6 "2025-11-19T06:32:07Z")

</div>

thanks a lot, i will try it today.

st 19. 11. 2025 o 6:53 Datadog via Ansible \<[notifications@ansible.discoursemail.com](mailto:notifications@ansible.discoursemail.com)\> napísal(a):
