# Debugging modules

**URL:** <https://forum.ansible.com/t/debugging-modules/18006>\
**Category:** Ansible Project\
**Created:** [April 17, 2015, 3:49pm UTC](https://forum.ansible.com/t/debugging-modules/18006 "2015-04-17T15:49:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christoph\_Haas](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@Christoph\_Haas](https://forum.ansible.com/u/Christoph_Haas)\
**Post date:** [April 17, 2015, 3:49pm UTC](https://forum.ansible.com/t/debugging-modules/18006/1 "2015-04-17T15:49:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 17, 2015, 5:25pm UTC](https://forum.ansible.com/t/debugging-modules/18006/2 "2015-04-17T17:25:56Z")

</div>

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.
