我有 python2.7
和 python3.5
在我的ansible
服务器,在执行剧本时它正在使用 python2.7
.我想要 ansible
使用 python3.5
执行剧本时。
in order:
1 have set export path.
2 also changed default interpreter path in ansible.cfg as well.
3 have given specific interpretor path in hostsfile for particular host.
但是,
ansible
未运行 python3
.
最佳答案
如果要为单个主机和组设置 Python 解释器,请设置 ansible_python_interpreter
库存变量。
但是,如果您想设置 Python 解释器以供全局使用,则设置 interpreter_python
键入[defaults]
配置文件中的部分ansible.cfg
.
有关上述两个选项的可能值的完整列表,请参阅:https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html
另请参阅此示例以了解 ansible_python_interpreter
的用法。 : https://docs.ansible.com/ansible/2.4/python_3_support.html ,“测试 Python 3 模块支持”部分。
关于python - 如何为 Ansible 剧本选择 Python 解释器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59380824/