Need to import code from ansible module

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

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.