我对 ansible 自动化相当陌生 我创建了一个剧本来在思科交换机上运行命令“show ip interface Brief”,然后使用 pyATS 解析输出(然后打印出来)
但是当我运行该剧时,它没有说出以下内容:
fatal: [IP removed]: FAILED! => {"changed": false, "msg": "/bin/sh: 1: show: not found\n", "stdout": "", "stdout_lines": []}
这是我的剧本:
---
- name: pyats parsing test
hosts: switches
gather_facts: no
tasks:
- name: show ip int br with pyats
ansible.utils.cli_parse:
command: "show ip interface brief"
parser:
name: ansible.netcommon.pyats
set_fact: sh_ip_int_parsed
- debug:
var: sh_ip_int_parsed
注意 - 我已经使用
cisco.ios.ios_command
模块在此交换机/主机组上运行了其他剧本
我仅在尝试使用 pyATS 时收到此错误(这是我尝试过的唯一输出解析器)
偶然发现了同样的问题,ansible utils 中存在一个错误,该错误已修复,但在通过 pip 安装时获得的版本中尚未修复: https://github.com/ansible-collections/ansible.utils/pull/357