Best way to debug developing ansible modules

Hi all,

I’m relatively new to ansible though I have been working on the nova_compute module and trying to try some ideas that I want to implement and have been trying to find the best way to debug code. Probably not the most elegant but certainly simplistic is the print() statement, which when I use it, doesn’t seem to print out when running a playbook. I notice there is a debug() call in library/internal/async_wrapper, though I’m wondering if there is something for modules in library/cloud that one can use?

Thanks in advance!

Best way to develop and hack on modules is the ./hacking/test-module script in the checkout. It can run a module and if you print things it will still give you output.

You can either use print based debugging (and remove them later) or even can insert debuggers.

Here’s some info on how I sometimes do it when I want to get into a debugger:

http://michaeldehaan.net/post/35403909347/tips-on-using-debuggers-with-ansible

Though most of the time, I use print and ./hacking/test-module too.

If the argument to “-a” starts with @, like “-a @args.json”, you can use a JSON file, which may be neccessary in passing structured data that many of the cloud modules can require.