python - 如何为 Ansible 剧本选择 Python 解释器?

标签 python ansible

我有 python2.7python3.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/

相关文章:

python - CMake 不链接 Python

python - 在子类对话框窗口中使用方法影响主窗口时出现问题

python - Snakemake,如何为两个独立参数构建循环

ansible - 如何在 Ansible 中加入字符串列表?

mysql - Ansible 在其他变量中使用加密变量

linux - 使用现有的 Ansible 角色创建自定义 Docker 镜像

variables - Ansible:在循环中生成变量

python - Django:如何在错误处理程序中获取异常实例

python - Python 中的开尔文函数 KelvinBer[n,z]

loops - 循环变量 Ansible 的多个值