05-29-2025 03:04 PM
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
Solved! Go to Solution.
05-30-2025 02:25 AM
Done with some internet searches
tasks:
- name: Remove user '99999999'
cisco.ios.ios_user:
name: "99999999"
state: absent
05-30-2025 02:25 AM
Done with some internet searches
tasks:
- name: Remove user '99999999'
cisco.ios.ios_user:
name: "99999999"
state: absent
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide