英文:
How can I get the output of an Ansible play as it is being run?
问题
默认情况下,Ansible会缓存所有输出(stdout
和stderr
),然后尝试以可读的方式呈现它。
这是可以启用/禁用的吗?
Ansible尝试以JSON格式呈现所有内容,有时会变得几乎无法阅读,就好像程序尝试输出一个JSON时会变得紧凑。
我能在任务完成之前获取程序传递给Ansible的输出吗?
英文:
By default a
Ansible will cache all the output (stdout
and stderr
) and then attempts to present it in a readable manner.
Is this something that can be enabled / disabled?
Ansible attempts to present everything in a JSON format and it sometimes ends up being almost unreadable as if the program attempts to output a JSON too it gets compacted.
Can I get the output as it is being given by the program to Ansible rather than wait for the task to finish?
答案1
得分: 0
由于您的帖子包含两个问题,一个关于格式化输出,另一个关于实时或流式日志,我希望专注于主要问题。
是否可以启用/禁用此功能?
不能直接。
我能否在程序将输出提供给Ansible时获取输出,而不必等待任务完成?
Ansible会在通常在远程托管节点上执行每个模块,并收集返回值。
以及
Ansible模块通常返回可以注册到变量中的数据结构...
因此,这种实时输出未实现。还请参阅如何显示实时的 shell
stdout
?
“实时”或“流式”输出尚未合并到Ansible中。 原问题 在2014年被关闭,因为不可行。 较新的提案 自2018年2月以来没有重大更新。
但是,如果需要的话,可以使用自定义模块调试或作为解决方法使用如何显示长时间运行的Ansible任务的进度?。
类似的问答
英文:
Since your post contains two questions, one about formatting output and the other about realtime or streaming logs, I like to focus on the main one.
> Is this something that can be enabled / disabled?
Not directly.
> Can I get the output as it is being given by the program to Ansible rather than wait for the task to finish?
It depends. According Introduction to modules and Return Values
> Ansible executes each module, usually on the remote managed node, and collects return values.
and
> Ansible modules normally return a data structure that can be registered into a variable ...
therefore such live output is not implemented. See also How to display realtime shell
stdout
?
> "Real time" or "streaming" output has not been merged to Ansible yet. The original issue was closed in 2014 as not feasible. A more recent proposal has no major updates since February 2018.
But there is a way if Debugging Custom Modules or as workaround How can I show progress for a long-running Ansible task?
Similar Q&A
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论