Debugging modules

Hi…

it assume that the mysql_user module is slightly buggy because it claims
"changed=1" after a privileges change although nothing was changed. But
I don't just like to complain but instead debug the module and see if I
can provide a fix. So far I have git-clone'd
git@github.com:ansible/ansible.git (recursively) and set

export
ANSIBLE_LIBRARY=/home/chaas/tmp/ansible/lib/ansible/modules/core/database/mysql/

I have copied the mysql_user.py to mysql_user2.py and started debugging.
However I wonder how I can debug the module. pdb didn't work as
expected. And neither STDOUT nor STDERR can be used. I even tried to
write to a "/tmp/debug" file but somehow even that didn't show anything.

So I wonder how developers actually debug their code. Hints welcome.

Thanks
…Christoph

In the ansible repo you can find the hacking/test-module script that
allows you to run/test a module and even attach a debugger to the run.

Other ways some people use is setting ANSIBLE_KEEP_REMOTE_FILES=1 and
using the resulting temporary files as python scripts under a
debugger.

One note with mysql, the latest version has made some backward
incompatible changes so and not all the module code paths have been
adjusted for that.