Guest Blog from Axians Alex Gittings: see original post on his blog
After using Ansible for a while I feel that I need to customize the appearance of the output to make it more user friendly, this is due to the default output not being very appealing.
This can be seen here…
Anstomlog is an opensource callback plugin for Ansible that has many cool features (taken from te README):
- one-line display
- pylint compatible (almost…)
- displays tasks content in a nice way
- including UTF-8 strings
- indents structs, displays empty arrays, strings
- puts fields on top when available [‘stdout’, ‘rc’, ‘stderr’, ‘start’, ‘end’, ‘msg’]
- removes some fields when present [, ‘stdout_lines’, ‘_ansible_verbose_always’, ‘_ansible_verbose_override’] to avoid too much clutter
- reverts to standard logger when more than vv verbosity
- supports no_log attribute in Task
- supports _ansible_verbose_always and _ansible_verbose_override
- supports multiple items in task (#1)
- multi host support
- correct duration computation
- diff display support
- displays stdout and stderr nicely even when they contain \n
- displays handlers calls
- Python 2/3 compatible
To install Anstomlog for your Ansible project there are a few things that are required:
- Firstly you need to navigate to your project directory –
cd ~/python/ansible/blogin my case.
- Create a directory within your ansible project called callbacks –
mkdir callbacks && cd callbacks
- Download the anstomlog.py file – `wget https://raw.githubusercontent.com/octplane/ansible_stdout_compact_logger/master/callbacks/anstomlog.py‘
- Now the plugin is in the correct folder you can now navigate back to your project directory which is in step 1.
- If there isn’t already create an ansible.cfg file within your project and insert the following configuration –
[defaults] callback_plugins= ./callbacks stdout_callback = anstomlog # Silence retry_files_enabled = False
- CONGRATULATIONS! You have successfully installed Anstomlog, go give it a go.
The finished output should looks similar to the following: