[英]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. 最佳做法是在执行使用Python和外部库创建的远程角色时,ansible复制python库。
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
我创建了一个有趣的剧本“ P1”,它正在调用角色“ R1”,该角色由一个
tasks/task.yml
文件组成,该文件正在/files/my_role.py
下调用一个Python文件。
This Python file uses a python library "L1" on local host. 该Python文件在本地主机上使用python库“ L1”。
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. 尝试远程执行ansible剧本时,ansible复制
.files/my_roles.py
文件,但在寻找.files/my_roles.py
无法复制的“ L1”模块时失败。
Is there any method in order to avoid such problem, and that ansible copies also the L1 library? 有什么方法可以避免这种问题,并且可以复制L1库吗?
No. 没有。
If you look at ansible modules' documentation, there are quite a bit of modules with requirements, like for example docker_container : 如果您查看ansible模块的文档,则有很多具有要求的模块,例如docker_container :
Requirements (on host that executes module)
要求(在执行模块的主机上)
python >= 2.6python> = 2.6
docker-py >= 1.7.0docker-py> = 1.7.0
Docker API >= 1.20Docker API> = 1.20
So you have to install those on destination host with package
or pip
first. 因此,您必须先使用
package
或pip
将其安装在目标主机上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.