无法使用ansible ping服务器

无法使用ansible ping服务器,ansible,ansible-2.x,Ansible,Ansible 2.x,我无法ping另一台服务器。我已经对SSH通信进行了身份验证。 请查找以下错误 ansible all-m ping-u ubuntu-i目录 WARNING]: Unhandled error in Python interpreter discovery for host 10.0.3.128: No JSON object could be decoded [WARNING]: Unhandled error in Python interpreter discovery for hos

我无法ping另一台服务器。我已经对SSH通信进行了身份验证。 请查找以下错误

ansible all-m ping-u ubuntu-i目录

WARNING]: Unhandled error in Python interpreter discovery for host 10.0.3.128: No JSON object could be decoded

[WARNING]: Unhandled error in Python interpreter discovery for host 10.0.3.53: No JSON object could be decoded

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named zipfile
[WARNING]: Platform linux on host 10.0.3.128 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.

10.0.3.128 | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "module_stderr": "Shared connection to 10.0.3.128 closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574742993.99-111761674559704/AnsiballZ_ping.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574742993.99-111761674559704/AnsiballZ_ping.py\", line 21, in _ansiballz_main\r\n    import zipfile\r\nImportError: No module named zipfile\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named zipfile
[WARNING]: Platform linux on host 10.0.3.53 is using the discovered Python interpreter at /usr/bin/python, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.

10.0.3.53 | FAILED! => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "module_stderr": "Shared connection to 10.0.3.53 closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574742994.0-31022973006547/AnsiballZ_ping.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ubuntu/.ansible/tmp/ansible-tmp-1574742994.0-31022973006547/AnsiballZ_ping.py\", line 21, in _ansiballz_main\r\n    import zipfile\r\nImportError: No module named zipfile\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
WARNING]:主机10.0.3.128的Python解释器发现中未处理的错误:无法解码JSON对象
[警告]:主机10.0.3.53的Python解释器发现中存在未经处理的错误:无法解码JSON对象
任务执行期间发生异常。要查看完整的回溯,请使用-vvv。错误为:ImportError:没有名为zipfile的模块
[警告]:主机10.0.3.128上的平台linux正在使用在/usr/bin/Python上发现的Python解释器,但将来安装另一个Python解释器可能会改变这一点。看见
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html 了解更多信息。
10.0.3.128 |失败!=>{
“可解释的事实”:{
“发现了解释器\u python”:“/usr/bin/python”
},
“更改”:错误,
“模块”\u stderr:“与10.0.3.128的共享连接已关闭。\r\n”,
“module_stdout”:“Traceback(最近一次调用):\r\n File\”/home/ubuntu/.ansible/tmp/ansible-tmp-1574742993.99-111761674559704/AnsiballZ_ping.py\”,第102行,在\r\n_AnsiballZ_main()\r\n File\“/home/ubuntu/.ansible/tmp/ansible/tmp/ansible-tmp-15747474793.99-111761674559704/AnsiballZ_ping.py中\“,第21行,在_ansiballz_main\r\n import zipfile\r\n导入错误:没有名为zipfile的模块\r\n”,
“msg”:“模块故障\n请参阅stdout/stderr以了解确切错误”,
“rc”:1
}
任务执行期间发生异常。若要查看完整回溯,请使用-vvv。错误为:ImportError:没有名为zipfile的模块
[警告]:主机10.0.3.53上的平台linux正在使用在/usr/bin/Python上发现的Python解释器,但将来安装另一个Python解释器可能会改变这一点。请参阅
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html 了解更多信息。
10.0.3.53 |失败!=>{
“可解释的事实”:{
“发现了解释器\u python”:“/usr/bin/python”
},
“更改”:错误,
“模块”\u stderr:“与10.0.3.53的共享连接已关闭。\r\n”,
“module_stdout:“Traceback(最近一次调用):\r\n File\”/home/ubuntu/.ansible/tmp/ansible-tmp-1574742974994.0-31022973006547/AnsiballZ_ping.py\”,第102行,在\r\n_AnsiballZ_main()\r\n File\“/home/ubuntu/.ansible/tmp/ansible/ansible-tmp-1574747944.0-3102297300447/AnsiballZ_ping.py\”,第21行,在_ansiballz_main\r\n import zipfile\r\n导入错误:没有名为zipfile的模块\r\n“,
“msg”:“模块故障\n请参阅stdout/stderr以了解确切错误”,
“rc”:1
}

Prasanna,转到10.0.3.128运行python,并尝试:

import zipfile

它似乎不是用它编译的,或者它找不到库,所以可能是环境问题。请作为ansible用户尝试一下。我收到了类似的错误并解决了它

创建容器后,我使用以下命令在其上安装python:

apt-get-install-python-minimal——不建议安装

但是,当我使用ansible ping命令得到“ImportError:No module named zipfile”错误时,我只是进入容器(使用lxc attach)并使用:

apt get install python


然后我的ansible ping命令按预期工作。

似乎ansible无法在客户端中找到python发行版。 最简单的解决方案是告诉ansible在
ansible.cfg
中的何处找到它。只需添加:

[defaults]
...
interpreter_python  = <pyhton path in client>
或对于较新版本(建议用于ansible):

像这样:

在大多数基于Debian的现代发行版中,python位于
/usr/bin/python3
这就形成了最终的解决方案:

[defaults]
...
interpreter_python  = /usr/bin/python3

请将一些回溯、参数
-vvv
作为错误状态包含在目标主机上运行的python版本中?它是否符合(即>2.6)?您确定它已正确安装/配置吗?并且应该是现成的。
which python3
[defaults]
...
interpreter_python  = /usr/bin/python3