There’s nothing to be ashamed of, we have all been there. Your Ansible playbook does not work.

You spent the last couple hours (yeah, right…) trying to understand what the hell is going on. Ansible does not shine in debugging tools unfortunately, so we’ll have to resort to the most powerful debugging method ever: print!

One way of getting the output of every single command is to run ansible or ansible-playbook with the -vvvv flag, which makes it very, very, very, very verbose.

It quikly gets very very messy too, if you are runnign your playbook on many instances at the same time.

To get the output of a single command, you have to use the debug module. The way it works is by asking Ansible to store the result of the command we want to diagnose in a variable using register on command or shell modules, then passing it to debug:

- name: List the home contents
  command: ls -la /home/admin
  register: ls_home

- debug:
  msg: "{{ ls_home.stdout }}"