我的Mellanox任务角色:
---
- name: set mellanox
set_fact:
ansible_network_os: 'onyx'
ansible_connection: network_cli
- name: configure interface Eth1/2
mellanox.onyx.onyx_interface:
name: Eth1/2
mtu: 1500我的剧本:
---
- hosts: mellanox_switch
gather_facts: no
roles:
- mellanox它产生的错误(冗长的3):
The full traceback is:
File "/tmp/ansible_mellanox.onyx.onyx_interface_payload_8h8n_8qc/ansible_mellanox.onyx.onyx_interface_payload.zip/ansible_collections/mellanox/onyx/plugins/module_utils/network/onyx/onyx.py", line 158, in get_capabilities
capabilities = connection.get_capabilities()
File "/tmp/ansible_mellanox.onyx.onyx_interface_payload_8h8n_8qc/ansible_mellanox.onyx.onyx_interface_payload.zip/ansible/module_utils/connection.py", line 200, in __rpc__
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [192.168.1.4]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"aggregate": null,
"delay": 10,
"description": null,
"enabled": null,
"mtu": 1500,
"name": "Eth1/2",
"purge": false,
"rx_rate": null,
"speed": null,
"state": "present",
"tx_rate": null
}
},
"msg": "show version | json-print\r\r\n% Unrecognized command \"json-print\".\r\nType \"?\" for help.\r\n\r [standalone: master] > "
}奇怪的是,onyx_command模块工作得很好:
---
# Mellanox management
- name: set mellanox
set_fact:
ansible_network_os: 'onyx'
ansible_connection: network_cli
- name: test show version
onyx_command:
commands: show version不知道是什么问题。我想这可能和安装有关。
发布于 2022-09-20 17:28:32
需要将下列行添加到剧本中
become: yes
become_method: enable发布于 2022-09-20 17:29:43
为什么Mellanox
onyx_interface模块失败了?
根据错误信息
show version | json-print
Unrecognized command "json-print"原因似乎与模块源代码module_utils/network/onyx/onyx.py有关。
社区收藏Mellanox Onyx模块模块管理Mellanox ONYX网络设备上的接口将从他自己的模块实用程序中导入(参见modules/onyx_interface)
from ansible_collections.mellanox.onyx.plugins.module_utils.network.onyx.onyx import BaseOnyxModule
from ansible_collections.mellanox.onyx.plugins.module_utils.network.onyx.onyx import get_interfaces_config并尝试查找远程设备的版本和功能。
它尝试将结果输出格式化为JSON
def show_cmd(module, cmd, json_fmt=True, fail_on_error=True):
if json_fmt:
cmd += " | json-print"
conn = get_connection(module)这个特定的命令| json-print不是在远程设备上不可用,就是没有功能,或者缺少权限。这也解释了为什么命令show version只起作用。
若要缩小原因,还应尝试执行
---
# Mellanox management
- name: Address Mellanox environment
set_fact:
ansible_network_os: 'onyx'
ansible_connection: network_cli
- name: Test 'show version'
onyx_command:
commands: show version | json-print
register: result
- name: Show result
debug:
var: resulthttps://stackoverflow.com/questions/73790068
复制相似问题