How to debug developing lookup plugins?

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

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.

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.