我正在尝试使用Ansible来自动化杜松设备上的某些命令。但是,这些命令要求我使用'|'(管道(。通过Junos_command模块文档阅读,无法使用管道。
This module does NOT use the Junos CLI to execute the CLI command. Instead, it uses the <command> RPC over a NETCONF channel. The <command> RPC takes a CLI command as it’s input and is very similar to executing the command on the CLI, but you can NOT include any pipe modifies (i.e. | match, | count, etc.) with the CLI commands executed by this module.
我尝试使用逃生字符,但是它仍然不起作用。
我想到的是通过Ansible to ssh使用Raw Shell命令到设备并运行命令(独立于Junos_command模块(,但这似乎是很多工作,我放弃了很多有用的功能,而不是使用。模块。
我可以采用哪种其他方法使用该模块通过管道传递命令。
您可以将输出作为XML格式恢复,而无需管道过滤。例如:
- name: show bgp summary with XML output
juniper_junos_command:
commands:
- "show bgp summary"
formats:
- "xml"
register: response
然后使用Ansible XML_Module将XPATH滤波器返回的输出。
https://docs.ansible.com/ansible/2.4/xml_module.html