0

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?

U880D
  • 8,601
  • 6
  • 24
  • 40
  • 4
    No, it is not meant for that. You do have a more readable output in YAML format though: https://stackoverflow.com/questions/50009505/ansible-stdout-formatting – β.εηοιτ.βε May 10 '23 at 13:46
  • Does [Is it possible to print out debugging logs while task is running in Ansible?](https://stackoverflow.com/a/71813720/6771046) answer your question? – U880D May 26 '23 at 13:59

1 Answers1

0

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

U880D
  • 8,601
  • 6
  • 24
  • 40