ansible_python_interpreter目标主机python路径 . 这对于具有多个Python或不位于“/ usr / bin / python”的系统(例如* BSD)或/ usr / bin / python不是2.X系列Python的系统非常有用 . 我们不使用“/ usr / bin / env”机制,因为它需要设置远程用户的路径,并假设“python”可执行文件名为python,其中可执行文件可能被命名为“python26” .
例如如果您在组级别指定它们,那么这就是您的库存文件的样子(当然,您也可以在主机级别指定您的选择):
# I think specifying ansible_ssh_host won't be needed, but if needed here is how it can be done.
# localhost ansible_ssh_host=127.0.0.1 ansible_python_interpreter=/usr/local/bin/python
localhost ansible_python_interpreter=/usr/local/bin/python
[rhel5-boxes]
rhelhost1
# ...
# other groups...
[rhel5-boxes:vars]
ansible_python_interpreter=/usr/bin/python2.6
[rhel6-boxes]
ansible_python_interpreter=/usr/bin/python
[iron-boxes:vars]
ansible_python_interpreter=/usr/bin/ipython
1 回答
Didn 't quite understand the overall picture, but does it help if you'能够使用“behavioral-inventory-parameter”为每个远程主机指定解释器:
例如如果您在组级别指定它们,那么这就是您的库存文件的样子(当然,您也可以在主机级别指定您的选择):