# How to debug developing lookup plugins?

**URL:** <https://forum.ansible.com/t/how-to-debug-developing-lookup-plugins/18525>\
**Category:** Ansible Project\
**Created:** [June 16, 2015, 10:19pm UTC](https://forum.ansible.com/t/how-to-debug-developing-lookup-plugins/18525 "2015-06-16T22:19:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasir\_Saleem](https://avatars.discourse-cdn.com/v4/letter/y/13edae/32.png) [@Yasir\_Saleem](https://forum.ansible.com/u/Yasir_Saleem)\
**Post date:** [June 16, 2015, 10:19pm UTC](https://forum.ansible.com/t/how-to-debug-developing-lookup-plugins/18525/1 "2015-06-16T22:19:04Z")

</div>

Hi,  
I am developing a lookup plugin to provide ‘Mime Multi Part archive’ data to 'nova\_compute module as ‘user\_data’

Code is doing something similar to what is shown here [http://bazaar.launchpad.net/~cloud-utils-dev/cloud-utils/trunk/view/head:/bin/write-mime-multipart](http://bazaar.launchpad.net/~cloud-utils-dev/cloud-utils/trunk/view/head:/bin/write-mime-multipart)

return from lookup plugin has every character separated by ‘,’. Which I am not sure where it is coming from

like

############ partial ansible console output Start ############

TASK: [openstack-instance | set\_fact] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
Terms: /var/folders/hb/x94mdg1n2qdd3n2c7zn2xdfr1gn4kj/T/cloudinit-XXXXXX.vDaFsyKs/lookup\_plugin\_test-jump/  
ok: [lookup\_plugin\_test-jump] =\> {“ansible\_facts”: {“multi\_part\_msg”: "C,o,n,t,e,n,t,-,T,y,p,e,:, ,m,u,l,t,i,p,a,r,t,/,m,i,x,e,d,;, ,b,o,u,n,d,a,r,y,=,",=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,0,2,2,1,2,6,1,9,6,0,0,4,5,3,7,6,2,5,8,=,=

############ partial ansible console output End ############

When I use the same code inside module I get the correct data. And it works fine. I am trying to debug what is going inside lookup plugin. Is there a way to debug lookup plugin?

BTW:

I am invoking lookup plugin as

- set\_fact:  
multi\_part\_msg: “{{ lookup(‘multipart\_mime’,‘/var/folders/hb/x94mdg1n2qdd3n2c7zn2xdfr1gn4kj/T/cloudinit-XXXXXX.vDaFsyKs/lookup\_plugin\_test-jump/’) }}”

Where ‘multipart\_mime’ is my lookup plugin, that converts the data in the given directory to ‘Mime Multi Part archive’ data as needed by nova\_compute module.

Thanks,  
Yasir.

---

<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:** [June 16, 2015, 11:31pm UTC](https://forum.ansible.com/t/how-to-debug-developing-lookup-plugins/18525/2 "2015-06-16T23:31:48Z")

</div>

You are expecting the input to always be a list, since strings are  
iterable in python it gets used as a list, try to detect if it is a  
string first and convert to a list if so, then it should work  
normally, listify function the other plugins use should do this for  
you.
