[英]Ansible - Unhandled error in Python interpreter discovery for
I have a problem trying to ping to machines using ansible, 1 is fedora 35 the 2nd is ubuntu 21. when I run我在尝试使用 ansible ping 机器时遇到问题,1 是 fedora 35,2nd 是 ubuntu 21。当我运行时
ansible all -i inventory -m ping -u salam -k
I get the following warnings我收到以下警告
[WARNING]: Unhandled error in Python interpreter discovery for host myubuntuIP: unexpected output from Python interpreter discovery [WARNING]: sftp transfer mechanism failed on [myubuntuIP].
[警告]:主机 myubuntuIP 的 Python 解释器发现中未处理的错误:Python 解释器发现的意外输出 [警告]:[myubuntuIP] 上的 sftp 传输机制失败。 Use ANSIBLE_DEBUG=1 to see detailed information [WARNING]: scp transfer mechanism failed on [myubuntuIP].
使用 ANSIBLE_DEBUG=1 查看详细信息 [WARNING]: scp transfer mechanism failed on [myubuntuIP]。 Use ANSIBLE_DEBUG=1 to see detailed information myubuntuIP |
使用ANSIBLE_DEBUG=1 查看详细信息 myubuntuIP | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" } [WARNING]: Platform unknown on host myfedoraIP is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change the meaning of that path.
SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "ping": "pong" } [警告]:主机 myfedoraIP 上的未知平台正在使用已发现的/usr/bin/python 中的 Python 解释器,但将来安装另一个 Python 解释器可能会改变该路径的含义。 See https://docs.ansible.com/ansible-core/2.14/reference_appendices/interpreter_discovery.html for more information.
有关详细信息,请参阅https://docs.ansible.com/ansible-core/2.14/reference_appendices/interpreter_discovery.html 。 myfedoraIP |
我的fedoraIP | SUCCESS => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong"
成功 => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "ping": "pong"
when I do当我做
which python3
on both machines, I get 2 different paths as follows在两台机器上,我得到 2 条不同的路径,如下所示
/usr/bin/python3 for fedora box /bin/python3 for ubuntu box
/usr/bin/python3 for fedora box /bin/python3 for ubuntu box
I understand from 1 thread here that we should indicate the path of python in ansible.cfg file, Can I indicate 2 different paths in the ansible.cfg?我从这里的 1 个线程了解到我们应该在 ansible.cfg 文件中指示 python 的路径,我可以在 ansible.cfg 中指示 2 个不同的路径吗? If yes how?
如果是怎么办? and why ansible is not able to find the python path?
为什么 ansible找不到python 路径?
First, the error on your Ubuntu system appears unrelated to this question;首先,你的 Ubuntu 系统上的错误似乎与这个问题无关; it says:
它说:
[WARNING]: sftp transfer mechanism failed on [myubuntuIP]
[WARNING]: scp transfer mechanism failed on [myubuntuIP]
I suspect to diagnose that issue you'll need to follow the instructions in the error message, set ANSIBLE_DEBUG=1
, and if the cause isn't immediately obvious open a new question here for that particular issue.我怀疑要诊断该问题,您需要按照错误消息中的说明进行操作,设置
ANSIBLE_DEBUG=1
,如果原因不是很明显,请在此处针对该特定问题打开一个新问题。
I understand from 1 thread here that we should indicate the path of python in ansible.cfg file, Can I indicate 2 different paths in the ansible.cfg?
我从这里的 1 个线程了解到我们应该在 ansible.cfg 文件中指示 python 的路径,我可以在 ansible.cfg 中指示 2 个不同的路径吗? If yes how?
如果是怎么办?
You don't set this in your ansible.cfg
(unless you really do want a single setting for all your hosts);你不要在你的
ansible.cfg
中设置它(除非你真的想要所有主机的单一设置); you set this in your Ansible inventory or in your host_vars
or group_vars
directory.您在 Ansible 清单或
host_vars
或group_vars
目录中设置它。 For example, to set this on a specific host in your inventory, you might do something like this:例如,要在清单中的特定主机上设置它,您可以执行如下操作:
all:
hosts:
host1:
ansible_python_interpreter: /usr/bin/python3
host2:
host3:
You could accomplish the same thing by placing:你可以通过放置来完成同样的事情:
ansible_python_interpreter: /usr/bin/python3
In host_vars/host1.yaml
.在
host_vars/host1.yaml
中。
If the same configuration applies to more than one host, you can group them and then apply the setting as a group variable.如果同一配置适用于多台主机,您可以将它们分组,然后将设置应用为组变量。 For example, to apply the setting only to a subset of your hosts:
例如,要仅将设置应用于主机的子集:
all:
hosts:
host1:
children:
fedora_hosts:
vars:
ansible_python_interpreter: /usr/bin/python3
hosts:
host2:
host3:
Or to apply it globally:或者在全球范围内应用它:
all:
vars:
ansible_python_interpreter: /usr/bin/python3
hosts:
host1:
host2:
host3:
And why ansible is not able to find the python path?
为什么 ansible 找不到 python 路径?
That's not what the warning is telling you -- it was able to find the Python path ( /usr/bin/python
), but "future installation of another Python interpreter could change the meaning of that path" (because /usr/bin/python
, depending on your distribution, could actually be python 2 instead of python 3, etc).这不是警告告诉你的——它能够找到 Python 路径(
/usr/bin/python
),但是“未来安装另一个 Python 解释器可能会改变该路径的含义”(因为/usr/bin/python
,具体取决于您的发行版,实际上可能是 python 2 而不是 python 3 等)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.