cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
193
Views
0
Helpful
1
Replies

How to remove local username via Using Ansible Script

bravealikhan
Level 1
Level 1

Hi, 

I want to remove local username from Cisco devices via Ansible Scipt, its required interactive action once we remove local username, Scipt is not working due to 2nd line confirmation, where we manully hit enter to confirm.

e.g.:

SW Cli: (config)#no username 99999999
This operation will remove all username related configurations with same name.Do you want to continue? [confirm] --Enter

-------- Ansible Script I'm using:

---
- name: Remove user 99999999 from Cisco devices with confirmation
hosts: cisco_devices
gather_facts: no
connection: network_cli

tasks:
- name: Send 'no username' command with confirmation
ios_command:
commands:
- no username 99999999
- ""

---------------------------------

Ansible 2.9.27

 

Any suggestion will be appreciated on how to give any code in Ansible which will hit [Enter] on the second line during scipt execution ?

 

 

Thanks you

1 Accepted Solution

Accepted Solutions

bravealikhan
Level 1
Level 1

Done with some internet searches 

tasks:
- name: Remove user '99999999'
cisco.ios.ios_user:
name: "99999999"
state: absent

View solution in original post

1 Reply 1

bravealikhan
Level 1
Level 1

Done with some internet searches 

tasks:
- name: Remove user '99999999'
cisco.ios.ios_user:
name: "99999999"
state: absent