我有一个可以像这样进行测试的可靠剧本
---
- name: "test"
hosts: localhost
tasks:
- name: "list files"
block:
- name: "list files"
command: /usr/bin/example-command -x -y -z
register: output
rescue:
- script: test.py {{ output.msg }}
args:
executable: python3
它会失败,我想捕获错误消息并将其发送到python脚本test.py(现在,我只是将消息写入文件
import sys
with open("/tmp/workfile", "w") as f:
f.write(sys.argv[1])
执行剧本,我查看了/tmp/workfile,我得到了
[Errno
为什么我没有收到完整的错误消息?
谢谢