Common functions for modules

19 views
Skip to first unread message

anders.a...@symsoft.com

unread,
Aug 19, 2015, 10:02:19 PM8/19/15
to Ansible Project
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

Brian Coca

unread,
Aug 21, 2015, 12:12:38 AM8/21/15
to Ansible Project
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/


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