# ios clear command expect confirm

**URL:** <https://forum.ansible.com/t/ios-clear-command-expect-confirm/22604>\
**Category:** Ansible Project\
**Created:** [September 21, 2016, 3:42pm UTC](https://forum.ansible.com/t/ios-clear-command-expect-confirm/22604 "2016-09-21T15:42:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Valerie\_P](https://avatars.discourse-cdn.com/v4/letter/v/f475e1/32.png) [@Valerie\_P](https://forum.ansible.com/u/Valerie_P)\
**Post date:** [September 21, 2016, 3:42pm UTC](https://forum.ansible.com/t/ios-clear-command-expect-confirm/22604/1 "2016-09-21T15:42:54Z")

</div>

Hi,

I have a question regarding the network core module “ios\_command”. I want to clear counters on some interfaces through a play. When I send the command directly through an SSH connection, the process is the following :

rtr-site6#clear counters GigabitEthernet 0/0  
Clear “show interface” counters on this interface [confirm]c

The router expects me to confirm the action. I tried to do it with the following play:

---

<div class="post-metadata">

**Author:** ![psprygada](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@psprygada](https://forum.ansible.com/u/psprygada)\
**Post date:** [September 22, 2016, 9:24pm UTC](https://forum.ansible.com/t/ios-clear-command-expect-confirm/22604/2 "2016-09-22T21:24:32Z")

</div>

In 2.1 there is no way to handle this.

We added a new capability in 2.2 (current devel branch) that will allow you to do this. The new task would look like this:

- name: Clear counters  
connection: local

tasks:

- ios\_command:  
host: “{{ inventory\_hostname }}”  
commands:
- command: "clear counters {{ item }} "  
prompt: ‘Clear “show interface” counters on this interface [confirm]’  
response: c  
with\_items:
- “{{ lan\_int }}”  
when:
- ‘“ce” in group\_names’

---

<div class="post-metadata">

**Author:** ![Valerie\_P](https://avatars.discourse-cdn.com/v4/letter/v/f475e1/32.png) [@Valerie\_P](https://forum.ansible.com/u/Valerie_P)\
**Post date:** [October 7, 2016, 3:36pm UTC](https://forum.ansible.com/t/ios-clear-command-expect-confirm/22604/3 "2016-10-07T15:36:03Z")

</div>

That is fantastic, thank you very much for your answer Peter!
