I am currently developing a number of Ansible modules using Python. My directory structure looks like this:
/
playbook.yml
library/
module1.py
module2.py
Using this, I can run the playbook (which uses my modules) via
ansible-playbook playbook.yml
Now I want to add a code file shared between my modules.
So I added the file library/shared.py
and added the line
from shared import my_shared_func
to all of my modules, so that I can call my_shared_func()
in all modules.
The problem is, that when calling ansible-playbook
again, this causes the error message
ModuleNotFoundError: No module named 'shared'
I am assuming, that Ansible is not copying the shared file to the execution host.
Can my problem be solved, or do all Ansible modules have to be completely self contained in a single file?