简体   繁体   English

Ansible最佳实践复制Python模块

[英]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.6 python> = 2.6
docker-py >= 1.7.0 docker-py> = 1.7.0
Docker API >= 1.20 Docker API> = 1.20

So you have to install those on destination host with package or pip first. 因此,您必须先使用packagepip将其安装在目标主机上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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