Display output with Ansible

Solution 1:

If you want more human friendly output define:

ANSIBLE_STDOUT_CALLBACK=debug

This will make ansible use the debug output module (previously named human_log) whinch despite its unfortunate name is less verbose and much easier to read by humans.

If you get an error that this module is not available, upgrade Ansible or add this module locally if you cannot upgrade ansible, it will work with over versions of ansible like 2.0 or probaly even 1.9.

Another option to configure this is to add stdout_callback = debug to your ansible.cfg

Solution 2:

There isn't a way to do what you want natively in Ansible. You can do this as a workaround:

ansible-playbook ... | sed 's/\\n/\n/g'

Solution 3:

Found this way in Ansible Project group forum:

- name: "Example test"
  command:
    ...
  register: test
- name: "Example test stdout"
  debug:
    msg: "{{ test.stdout.split('\n') }}"
- name: "Example test stderr"
  debug:
    msg: "{{ test.stderr.split('\n') }}"

We basically turn this into list by splitting it by newline and then printing that list.


Solution 4:

You can use a callback plugin. This will re-parse your output and is easily turned on and off.

Tags:

Ansible