如何在不替换换行符的情况下将Ansible配置为输出错误?

问题描述 投票:5回答:2

似乎ansible返回结果使用JSON格式,在输出中用\n替换换行符。

这使得很难读取屏幕/日志上的输出。如何配置它以使用真实换行符?

ansible
2个回答
1
投票

您需要在ansible.cfg文件中使用回调插件...

[defaults]
(...)
stdout_callback=debug
stderr_callback=debug

将解决你的问题...不要问为什么它不是默认的,因为我真的不能说。

注意:这仅适用于Ansible 2.0.0及更高版本。


0
投票

使用from_json过滤器

  tasks:
    - name: Execute the command/script
      shell: <some command>
      register: result
    - debug: var=result.stdout | from_json
© www.soinside.com 2019 - 2024. All rights reserved.