-1

默认配置中的 Ansible 是否可以与其他供应商一起使用?比如华为?

如果我正在运行一些测试命令,例如:

sudo ansible -m shell -a '显示版本' 服务器

10.46.1.1 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: \r\n**********************************************************************\r\n* Jus esate prisijunge prie privacios irangos. Visi veiksmai,vykdomi *\r\n* su sia iranga, yra fiksuojami. Tam, kad prieiti prie sios irangos  *\r\n* ir (ar) atlikti irangos konfiguracija ar kitus veiksmus, jus turite*\r\n* tureti atitinkama leidima.                                         *\r\n* Uz neteiseta prisijungima bei neteisetus veiksmus su iranga taikoma*\r\n* istatymuose numatyta atsakomybe,iskaitant ir baudziamaja atsakomybe*\r\n* Prasome  atsijungti.Jeigu  jus esate   autorizuotas  vartotojas,   *\r\n* prisijungdamas, jus atsakote uz teisingai atlikta konfiguracija ir *\r\n* kitus savo vardu atliktus veiksmus.                                *\r\n**********************************************************************\r\n* You are connected to private equipment. All the actions performed  *\r\n* with the equipment are recorded. In order to access this equipment *\r\n* and (or) perform its configuration or other  actions, you must have*\r\n* an appropriate permission. Illegal connection and illegal actions  *\r\n* with the equipment.                                                *\r\n* Will be subject to liability, including criminal liability, as     *\r\n* provided for in the laws of the Republic of Lithuania. Please      *\r\n* disconnect immediately. If you are an authorized user, by          *\r\n* connecting  to the equipment, you assume liability for performing  *\r\n* correct configuration and other actions under your behalf.         *\r\n**********************************************************************\r\nUser Authentication\r\npacket_write_wait: Connection to 10.46.1.1 port 22: Broken pipe\r\n",
    "unreachable": true
}

或者

osboxes@osboxes:~$ sudo ansible -m ping 服务器

10.46.1.1 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: \r\n**********************************************************************\r\n* Jus esate prisijunge prie privacios irangos. Visi veiksmai,vykdomi *\r\n* su sia iranga, yra fiksuojami. Tam, kad prieiti prie sios irangos  *\r\n* ir (ar) atlikti irangos konfiguracija ar kitus veiksmus, jus turite*\r\n* tureti atitinkama leidima.                                         *\r\n* Uz neteiseta prisijungima bei neteisetus veiksmus su iranga taikoma*\r\n* istatymuose numatyta atsakomybe,iskaitant ir baudziamaja atsakomybe*\r\n* Prasome  atsijungti.Jeigu  jus esate   autorizuotas  vartotojas,   *\r\n* prisijungdamas, jus atsakote uz teisingai atlikta konfiguracija ir *\r\n* kitus savo vardu atliktus veiksmus.                                *\r\n**********************************************************************\r\n* You are connected to private equipment. All the actions performed  *\r\n* with the equipment are recorded. In order to access this equipment *\r\n* and (or) perform its configuration or other  actions, you must have*\r\n* an appropriate permission. Illegal connection and illegal actions  *\r\n* with the equipment.                                                *\r\n* Will be subject to liability, including criminal liability, as     *\r\n* provided for in the laws of the Republic of Lithuania. Please      *\r\n* disconnect immediately. If you are an authorized user, by          *\r\n* connecting  to the equipment, you assume liability for performing  *\r\n* correct configuration and other actions under your behalf.         *\r\n**********************************************************************\r\nUser Authentication\r\nchannel_by_id: 2: bad id: channel free\r\nDisconnecting: Received data for nonexistent channel 2.\r\n",
    "unreachable": true
}

它只是连接并立即断开连接而无需输入任何命令,例如“显示版本”。可能是因为我不在 Cisco 设备上运行它,而是在其他供应商上运行它?也许需要一些特殊的模块?

谢谢

4

2 回答 2

0

您可以使用“shell”以外的其他模块来访问华为设备。如果你看这里,你会看到一些 Cloud Engine 模块。Shell 模块用于服务器,而不用于交换机。

所以,我会写这样的东西: ansible -m ce_command -a 'display version' servers

于 2017-12-04T13:12:30.687 回答
0

您是否确认可以通过 ssh 正常连接到这些机器?您是否在尝试连接的机器上创建了 ansible 帐户?听起来像是试图在您的主机上运行 ansible 的用户帐户,可能在主机上没有 ssh 密钥。你有没有尝试过

ssh-copy-id ansible@host

并确认您可以登录该主机

ssh ansible@host

用钥匙?

于 2017-05-25T19:02:34.667 回答