ansible中的系统特定变量
Ansible期望python 2。在我的系统(Arch Linux)上,“python”是python 3,因此我必须在每个命令中传递ansible中的系统特定变量,ansible,Ansible,Ansible期望python 2。在我的系统(Arch Linux)上,“python”是python 3,因此我必须在每个命令中传递-e“ansible\u python\u解释器=/usr/bin/python2” ansible-playbook my-playbook.yml -e "ansible_python_interpreter=/usr/bin/python2" 在我的系统上是否有一个可以全局设置ansible\u python\u解释器的解释器,这样我就不必将它传递给每个
-e“ansible\u python\u解释器=/usr/bin/python2”
ansible-playbook my-playbook.yml -e "ansible_python_interpreter=/usr/bin/python2"
在我的系统上是否有一个可以全局设置
ansible\u python\u解释器的解释器
,这样我就不必将它传递给每个命令了?我不想将其添加到我的剧本中,因为并非所有运行剧本的系统都有类似于我的设置。您可以通过三种方式进行设置
ansible\u python\u解释器=/usr/bin/python2
这将为每个主机设置它ansible\u python\u解释器:“/usr/bin/python2”
这将为每个主机设置它组变量/all
中的所有节点(您可能需要创建目录组变量
和文件所有
),作为ansible_python_解释器:“/usr/bin/python2”
希望这会有所帮助我选择使用Ansible的功能从目录中获取库存。通过这种方式,我可以仅为本地计算机定义本地主机的
ansible\u python\u解释器
inventory\u dir/local
[local]
localhost ansible_python_interpreter="/path/to/alternate/bin/python"
然后像使用库存文件一样使用目录
ansible playbook-i inventory\u dir playbook.yml
适用于希望使用本地激活的virtualenv python解释器的用户
在库存中
文件集
[local]
localhost ansible_python_interpreter=python
我不希望它出现在剧本中的任何地方,这就是重点:)我的机器上需要ansible python2这一事实不应该影响使用剧本的其他人。首先,上面只改变了剧本中的目录主机和组。但是您是在管理ArchLinux还是混合环境?这并不是真正的答案。我也在寻找一个不涉及剧本的解决方案,因为我使用Ansible Tower,当使用GIT项目时,它使用Ansible的Python2.6和加密错误,而我的Ansible Tower有2.7库!这不涉及剧本。这在以下内容中定义:a)清单文件b)主机变量或c)组变量。你没有改变剧本或这个级别的任何角色,因此100%可移植。我建议您将组_varsy命名为
inventory
(您没有调用local
local_file
):D