# Ansible custom module and custom python library

**URL:** <https://forum.ansible.com/t/ansible-custom-module-and-custom-python-library/23609>\
**Category:** Ansible Project\
**Created:** [February 1, 2017, 8:25am UTC](https://forum.ansible.com/t/ansible-custom-module-and-custom-python-library/23609 "2017-02-01T08:25:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julien\_Buonocore](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@Julien\_Buonocore](https://forum.ansible.com/u/Julien_Buonocore)\
**Post date:** [February 1, 2017, 8:25am UTC](https://forum.ansible.com/t/ansible-custom-module-and-custom-python-library/23609/1 "2017-02-01T08:25:43Z")

</div>

Hello,

As part of the deployment of an application specific to the business of my company, I developed modules Ansible in Python and for reuse and factorization of code, I also developed a Python library. A bootable playbook installs the Python library on the managed hosts, and then the module that I developed in Python loads this library.

My question: is this way of organizing my developments in conformity with the philosophy of Ansible, especially on the fact that the modules are supposed to be standalone?

Do you think that can be a problem later on?

Thanks for your feedback,

Julien.

---

<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:** [February 6, 2017, 2:48pm UTC](https://forum.ansible.com/t/ansible-custom-module-and-custom-python-library/23609/2 "2017-02-06T14:48:05Z")

</div>

In current development (2.3) we've added a 'user definable  
module\_utils' as a way to share code across custom modules, the same  
way we currently do with the shipped lib/ansible/module\_utils for all  
modules. It works as library/ and other \<x\>\_plugins directories as you  
can just add them adjacent to play or in role. A config setting and  
var will be created soon to complete the options as for other plugins.

---

<div class="post-metadata">

**Author:** ![Joseph\_Lorenzini](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joseph\_Lorenzini](https://forum.ansible.com/u/Joseph_Lorenzini)\
**Post date:** [April 23, 2017, 1:30pm UTC](https://forum.ansible.com/t/ansible-custom-module-and-custom-python-library/23609/3 "2017-04-23T13:30:41Z")

</div>

Hello,

I am quite interested in using this functionality and I am on ansible 2.3. However, I was unable to find any documentation on how to use this. Simply setting the environment variable ANSIBLE\_MODULE\_UTILS\_PATH doesn’t seem to work.

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![ylamgarc](https://avatars.discourse-cdn.com/v4/letter/y/fbc32d/32.png) [@ylamgarc](https://forum.ansible.com/u/ylamgarc)\
**Post date:** [July 3, 2017, 12:30pm UTC](https://forum.ansible.com/t/ansible-custom-module-and-custom-python-library/23609/4 "2017-07-03T12:30:23Z")

</div>

Hello,

I’m also interested by this feature, any news/documentation on that ?

Thanks,

Yassine

---

<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:** [July 3, 2017, 3:53pm UTC](https://forum.ansible.com/t/ansible-custom-module-and-custom-python-library/23609/5 "2017-07-03T15:53:28Z")

</div>

docs are basically the same as my response, use a module\_utils/ dir  
adjactent to play/in role or specify a dir in config in the path  
entry, then you can use just like anything in the shipped ansible  
module\_utils dir.

---

<div class="post-metadata">

**Author:** ![ylamgarc](https://avatars.discourse-cdn.com/v4/letter/y/fbc32d/32.png) [@ylamgarc](https://forum.ansible.com/u/ylamgarc)\
**Post date:** [July 5, 2017, 3:59pm UTC](https://forum.ansible.com/t/ansible-custom-module-and-custom-python-library/23609/6 "2017-07-05T15:59:09Z")

</div>

It works, thanks Brian !
