无用户名登录的Ansible telnet

无用户名登录的Ansible telnet,ansible,telnet,cisco,Ansible,Telnet,Cisco,我需要使用ansible telnet模块连接到cisco设备(我无法启用SSH)。 在我在网上找到的所有教程中,每个人都在指定登录用户名和密码,以便在telnet中进行身份验证 但是我的路由器不需要用户名,auth提示符直接从mesage开始: Password: 这是我的档案: inventory.yml: [cisco] test ip_address=xxx.yyy.zzz [cisco:vars] password=test password_enable=test plays/

我需要使用ansible telnet模块连接到cisco设备(我无法启用SSH)。 在我在网上找到的所有教程中,每个人都在指定登录用户名和密码,以便在telnet中进行身份验证

但是我的路由器不需要用户名,auth提示符直接从mesage开始:

Password:
这是我的档案:

inventory.yml:

[cisco]
test ip_address=xxx.yyy.zzz

[cisco:vars]
password=test
password_enable=test
plays/cisco.yml:

---

- hosts: cisco
  connection: local
  roles:
    - role: cisco-telnet
角色/cisco telnet/tasks/main.yml:

---
- name: Telnet test
  telnet:
    host: "{{ ip_address }}"
    port: 23
    password_prompt: "Password:"
    password: "{{ password }}"
    prompts:
      - '[>|#]'
    command:
      - enable
      - "{{ password_enable }}"
      - show running-config
每次我都会收到一条错误消息:

FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}

如何在不指定用户名的情况下使用telnet模块?有人已经这样做了?

研究的源代码并阅读,我假设以下行为:

如果
密码
为空,则不会出现
密码提示

因此,您可以对
密码使用
登录提示
。有点奇怪,所以我想下面的代码片段应该可以工作:

- name: Telnet test
  telnet:
    host: "{{ ip_address }}"
    port: 23
    login_prompt: "Password:"
    user: "{{ password }}"
    prompts:
      - '[>|#]'
    command:
      - enable
      - "{{ password_enable }}"
      - show running-config
我无法测试它,因为我没有telnet服务器了,你已经晚了20年;-)