Best way to debug developing ansible modules

144 views
Skip to first unread message

Patrick Galbraith

unread,
Apr 2, 2014, 3:48:42 PM4/2/14
to ansible...@googlegroups.com
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!

Michael DeHaan

unread,
Apr 2, 2014, 4:26:47 PM4/2/14
to ansible...@googlegroups.com
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:


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.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b3656bd0-5cef-4c54-a416-441765bbbc16%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages