擅长:python、mysql、java
<p>有一种方法可以解决这个问题,它将显示实时输出,但是您必须在每一行处理注入的前缀。这很混乱/有点黑,但为了调试/监视的目的,它完成了工作:</p>
<pre><code>- name: Run some command and echo it's realtime stdout
shell: ":"
with_lines: "/usr/bin/some_long_running_command with arguments and such here"
</code></pre>
<p>命令<code>:</code>只是一个noop,如果更简单的话,您可以轻松地使用<code>command: /usr/bin/true</code>。在任何情况下,这将输出类似于:</p>
<pre><code>changed: [localhost] => (item=first output line)
changed: [localhost] => (item=second output line)
changed: [localhost] => (item=third output line)
</code></pre>