使用 ansible 删除 Cisco IOS 用户

Removing Cisco IOS users with ansible

我正在尝试使用 ansible 删除 Cisco IOS 交换机和路由器上的一些旧用户。由于 IOS 提示用户在 CLI 上确认他们是否要删除用户名这一事实,ansible 任务当前失败。有什么办法可以解决这个问题吗?

这是一个 CLI 示例

SW01(config)#no username admin
This operation will remove all username related configurations with same name.Do you want to continue? [confirm]

ansible 任务

  tasks:
    - name: Remove username
      ios_command:
         commands: no username admin

使用ios_user模块。在这里查看更多详细信息:https://docs.ansible.com/ansible/latest/modules/ios_user_module.html#ios-user-module

示例:

- name: Delete a user account
  ios_user:
    name: "neo"
    state: absent