# Common functions for modules

**URL:** <https://forum.ansible.com/t/common-functions-for-modules/19047>\
**Category:** Ansible Project\
**Created:** [August 19, 2015, 6:38am UTC](https://forum.ansible.com/t/common-functions-for-modules/19047 "2015-08-19T06:38:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anders.andersson](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@anders.andersson](https://forum.ansible.com/u/anders.andersson)\
**Post date:** [August 19, 2015, 6:38am UTC](https://forum.ansible.com/t/common-functions-for-modules/19047/1 "2015-08-19T06:38:18Z")

</div>

Greetings all.

Is it possible to import a shared module in to a role module?

Something like:

roles/  
myRole1/  
library/  
myFunc1.py ← import myCommon

myRole2/  
library/  
myFunc2.py ← import myCommon

some\_dir/  
myCommon.py

Where myCommon.py contain functions that can be used for all roles. E.g. update\_something\_common().

Thanks.  
/Anders

---

<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:** [August 21, 2015, 4:12am UTC](https://forum.ansible.com/t/common-functions-for-modules/19047/2 "2015-08-21T04:12:31Z")

</div>

no, currently this does not exist, the libraries a module uses should  
be installed in the system.

ansible uses a non standard import to share code between modules, that  
shared code lives in module\_utils/
