简体   繁体   中英

ansible best practice copy Python module

What is the best practice in order that ansible copy a python library while executing a remote role which is a created using Python and using a external library.

Here is my use case :

I have create an ansible playbook "P1" which is calling a role "R1", the role is composed by a tasks/task.yml file which is calling a Python file under /files/my_role.py

This Python file uses a python library "L1" on local host.

When trying to execute the ansible playbook remotely, ansible copies the .files/my_roles.py file but fails while looking for the "L1" module which isn't copied by ansible.

Is there any method in order to avoid such problem, and that ansible copies also the L1 library?

No.

If you look at ansible modules' documentation, there are quite a bit of modules with requirements, like for example docker_container :

Requirements (on host that executes module)
python >= 2.6
docker-py >= 1.7.0
Docker API >= 1.20

So you have to install those on destination host with package or pip first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM