hassek

Remember

My code snippets

Debugging variables in Ansible can be a pain sometimes, to make it easier there are debug modules to help out with it.


ansible -m debug -a "msg={{hostvars[inventory_hostname]}}" -i \
  inventories/vagrant/hosts mahmachine.localhost

This will print all the variables belonging to the pointed inventory, also, we could add debug strategy on a playbook too:

# playbook.yml
- hosts: mahmachine.localhost
  strategy: debug
  roles:
    - base

And if there is any issue with the playbook it will open a kind of pdb/gdb so you can interactively investigate!