Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clean error output in ansible-playbook

If any Ansible task fails, there is error output, the playbook will display it newlines escaped '\n'. For tracebacks, spanning multiple lines, this make it very hard to read.

Is there a way to make ansible-playbook to display unescaped error output from shell, pip, gitand other similar tasks?

like image 914
Mikko Ohtamaa Avatar asked May 11 '16 19:05

Mikko Ohtamaa


People also ask

How do I ignore fatal errors in Ansible?

Ignoring failed commands By default Ansible stops executing tasks on a host when a task fails on that host. You can use ignore_errors to continue on in spite of the failure. The ignore_errors directive only works when the task is able to run and returns a value of 'failed'.

How can Error Handling be done in Ansible?

Ansible normally has defaults that make sure to check the return codes of commands and modules and it fails fast – forcing an error to be dealt with unless you decide otherwise. Sometimes a command that returns different than 0 isn't an error.

How do you capture command output in Ansible?

To capture the output, you need to specify your own variable into which the output will be saved. To achieve this, we use the 'register' parameter to record the output to a variable. Then use the 'debug' module to display the variable's content to standard out.


1 Answers

Add stdout_callback=debug and stderr_callback=debug in the defaults section of your ansible.cfg file.

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

This is supported by ansible > 2.0

like image 168
Stefano Avatar answered Oct 01 '22 01:10

Stefano