# Need to import code from ansible module

**URL:** <https://forum.ansible.com/t/need-to-import-code-from-ansible-module/22938>\
**Category:** Ansible Developer\
**Created:** [November 2, 2016, 12:57am UTC](https://forum.ansible.com/t/need-to-import-code-from-ansible-module/22938 "2016-11-02T00:57:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evelio\_VILA](https://avatars.discourse-cdn.com/v4/letter/e/f19dbf/32.png) [@Evelio\_VILA](https://forum.ansible.com/u/Evelio_VILA)\
**Post date:** [November 2, 2016, 12:57am UTC](https://forum.ansible.com/t/need-to-import-code-from-ansible-module/22938/1 "2016-11-02T00:57:57Z")

</div>

Hello list!

So basically I need to import some python code from an Ansible custom module. I can’t put that code under the  
Ansible utils repo. What would be the best solution to accomplish this?

From what I can see Ansible seems to rename the module and then bundle all libs in a file in the hope that the libraries  
used by my custom module are there. This is however not the case.

From the a debug output i added to my custom module I can see the directory listing looks like:

ansible\_modlib.zip and my renamed module prefixed by ansible\_module\_\*

I also tried adding my lib to the same directory as my custom module and add an **init**.py file, but the import fails  
to find the lib.

Any ideas here?

Thanks,  
Evelio

---

<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:** [November 2, 2016, 2:00pm UTC](https://forum.ansible.com/t/need-to-import-code-from-ansible-module/22938/2 "2016-11-02T14:00:15Z")

</div>

This is not currently supported, modules need to rely on libraries existing on the target system. The exception is shared code in Ansible itself under the module\_utils directory. We do have plans to enable this shared code on a ‘user directory’ basis, but we don’t have anything implemented yet.
