ios clear command expect confirm

370 views
Skip to first unread message

Valérie P

unread,
Sep 21, 2016, 1:26:42 PM9/21/16
to Ansible Project
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: 

---

- name: Clear counters
  connection: local
  ios_command:
    host: "{{ inventory_hostname }}"
    commands:
      - "clear counters {{ item }} "
  with_items:
    - "{{ lan_int }}"
  when: 
    - '"ce" in group_names'


But I received this error

failed: [rtr-site6] (item=GigabitEthernet0/0) => {"failed": true, "item": "GigabitEthernet0/0", "msg": "timeout trying to send command: clear counters GigabitEthernet0/0 \r"}


Is there a way to "confirm" this command with any network modules? I am using this on a Cisco 2921, here is the version.
Cisco IOS Software, C2900 Software (C2900-UNIVERSALK9-M), Version 15.5(3)M1, RELEASE SOFTWARE (fc2)

Kind regards! 

Valerie

Peter Sprygada

unread,
Sep 22, 2016, 5:24:37 PM9/22/16
to ansible...@googlegroups.com
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'

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/fa4e7132-b296-460e-851a-d2f92f65bf78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Valérie P

unread,
Oct 7, 2016, 11:36:03 AM10/7/16
to Ansible Project
That is fantastic, thank you very much for your answer Peter!
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages