【发布时间】:2021-06-22 15:55:55
【问题描述】:
当使用 iosxr_command 模块向 cisco 设备发送任意命令并保存输出时,即使设备返回命令语法错误,如何保持输出,而不是认为任务失败?
剧本:
- name: run command and save output
iosxr_command:
commands:
- "invalid syntax command"
register: output
预期保存的输出:
RP/0/RSP0/CPU0:IOSXR_ROUTER#invalid syntax command
^
% Invalid input detected at '^' marker.
代替:
TASK [run command and save output]
*****************************************************************************************************************
failed: [IOSXR_ROUTER] (item=invalid syntax command) => {"changed": false, "item": "invalid command",
"msg": "invalid syntax command\r\n\r
^\r\n% Invalid input detected at '^' marker.\r\nRP/0/RSP0/CPU0:IOSXR_ROUTER#"}
【问题讨论】:
-
@mdaniel 我已经尝试过了,当命令执行失败时,我仍然需要编辑剧本以使用 output.msg 的内容而不是 output.stdout,然后我得到了我想要的。谢谢你:)