您需要在ansible.cfg文件中使用回调插件...
[defaults]
(...)
stdout_callback=debug
stderr_callback=debug
Run Code Online (Sandbox Code Playgroud)
会解决你的问题...不要问为什么它不是默认的,因为我真的说不出来。
注意:这仅在 Ansible2.0.0及更高版本中可用。
使用from_json过滤器
tasks:
- name: Execute the command/script
shell: <some command>
register: result
- debug: var=result.stdout | from_json
Run Code Online (Sandbox Code Playgroud)