似乎ansible返回结果使用JSON格式,在输出中用\n
替换换行符。
这使得很难读取屏幕/日志上的输出。如何配置它以使用真实换行符?
您需要在ansible.cfg
文件中使用回调插件...
[defaults]
(...)
stdout_callback=debug
stderr_callback=debug
将解决你的问题...不要问为什么它不是默认的,因为我真的不能说。
注意:这仅适用于Ansible 2.0.0
及更高版本。
使用from_json
过滤器
tasks:
- name: Execute the command/script
shell: <some command>
register: result
- debug: var=result.stdout | from_json