I'm trying to use ansible to remove some old users on Cisco IOS switches and routers. The ansible task is currently failing due to the fact that IOS prompts the user on the CLI to confirm if they want to remove the username. Any way around this with ansible?
Here is a CLI example
SW01(config)#no username admin
This operation will remove all username related configurations with same name.Do you want to continue? [confirm]
ansible task
tasks:
- name: Remove username
ios_command:
commands: no username admin
Use ios_user
module. Look here for more details: https://docs.ansible.com/ansible/latest/modules/ios_user_module.html#ios-user-module
Example:
- name: Delete a user account
ios_user:
name: "neo"
state: absent