How to debug developing lookup plugins?

57 views
Skip to first unread message

Yasir Saleem

unread,
Jun 16, 2015, 6:19:04 PM6/16/15
to ansible...@googlegroups.com
Hi, 
  I am developing a lookup plugin to provide 'Mime Multi Part archive' data to 'nova_compute module as 'user_data' 


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.

Brian Coca

unread,
Jun 16, 2015, 7:31:51 PM6/16/15
to ansible...@googlegroups.com
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.
> --
> 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/246f87ad-8514-49a6-8dda-5cafb0a44756%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages