Ansible Python解释器问题 [英] Ansible Python interpreter Issue
问题描述
我正在尝试在虚拟环境中将Python解释器更改为Im.而且我还将在仅具有python2的Jenkins服务器上部署venv.因此....
Im trying to change the Python interpreter as Im in a virtual environment. But also I will be deploying the venv on a Jenkins server that only has python2. Hence....
# grep python ansible/ansible.cfg
interpreter_python = ./venv/bin/python2
ansible --version | grep "python version"
python version = 3.5.2 (default, Nov 12 2018, 13:43:14) [GCC 5.4.0 20160609]
我想念什么?
推荐答案
检查在文档的受管机器上使用带有命令和剧本的Python3" 部分.该部分是针对 python3
的,但最终使用哪个版本的python确实无关紧要.在该文章上,您会看到以下报价:
Check the "Using Python3 on the managed machines with commands and playbooks" section of the Docs. The piece is for python3
but it truly doesn't matter which version of python you end up using. On that article you'll see this quote:
要显式配置Python 3解释器,请在组或主机级别将
ansible_python_interpreter
清单变量设置为Python 3解释器的位置,例如/usr/bin/python3
.默认解释器路径也可以在ansible.cfg
中设置.
To explicitly configure a Python 3 interpreter, set the
ansible_python_interpreter
inventory variable at a group or host level to the location of a Python 3 interpreter, such as/usr/bin/python3
. The default interpreter path may also be set inansible.cfg
.
因此,只需将 ansible_python_interpreter
设置为对您的 hosts
主机有意义的级别.
So, just set the ansible_python_interpreter
at the level that makes sense for your hosts
.
这篇关于Ansible Python解释器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!