我正在尝试将 Python 解释器更改为虚拟环境中的 Im。 但我也会在只有 python2 的 Jenkins 服务器上部署 venv。因此....
# 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]
我错过了什么?
最佳答案
检查 "Using Python3 on the managed machines with commands and playbooks"文档的一部分。该文章适用于 python3
,但您最终使用哪个版本的 python 并不重要。在那篇文章中,您会看到这句话:
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
有意义的级别。
关于Ansible Python 解释器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57327133/