关于ansible_python_interp的查询

2024-10-01 19:31:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我有500多个目标服务器有一个与ansible兼容的python version 2.7 安装在不同的位置,如下图所示。在

/usr/bin/python /opt/apps/xerto/tools/ansible/bin/python2.7

/opt/atlassian/tools/ansible/bin/python2.7

/opt/wsp/apps/ansible/python2.7/bin/python2.7

/opt/wsp/apps/tools/ansible/python2.7/bin/python2.7

/opt/docs/python/bin/python2.7

/home/admin/ansible/bin/python2.7

/opt/operations/Python-2.7.8/bin/python

/opt/ora/python/bin/python2.7

/opt/tomcat/tools/ansible/bin/python2.7

每次我必须根据ansible要连接的目标服务器,在ansible主机文件中为ansible_python_interpreter设置上述python路径。在

我的目的是对目标服务器进行很少或根本不做任何更改,而是在ansible端处理这个问题。在

有没有一种聪明的方法可以让ansible找出所需的python在哪里?在

请提出建议。在

Ansible version: 2.7.1

Tags: apps服务器docs目标homebinadminversion
1条回答
网友
1楼 · 发布于 2024-10-01 19:31:22

Is there a clever way to have ansible figure out where the desired python is?

^{1}$

我认为使用shell迭代也可以做到这一点,但我没有对其进行测试,也没有考虑所有的边缘情况:

^{pr2}$

相关问题 更多 >

    热门问题