ios clear command expect confirm

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:

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’

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