ansible ping远程主机debian11报错
前言:
debian 11自带python版本过高3.11 ansible主机版本为2.9.27 需要降python版本为3.8.10,ansible 2.9.27 要求远程机器python不得高于3.9
-
Python 2.7
-
Python 3.5
-
Python 3.6
-
Python 3.7
-
make -j 2
The full traceback is: Traceback (most recent call last): File "<frozen zipimport>", line 520, in _get_decompress_func ModuleNotFoundError: No module named 'zlib' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<frozen zipimport>", line 568, in _get_data File "<frozen zipimport>", line 523, in _get_decompress_func zipimport.ZipImportError: can't decompress data; zlib not available During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/root/.ansible/tmp/ansible-tmp-1685592358.26-1767-102413995694194/AnsiballZ_ping.py", _ansiballz_main() File "/root/.ansible/tmp/ansible-tmp-1685592358.26-1767-102413995694194/AnsiballZ_ping.py", invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS) File "/root/.ansible/tmp/ansible-tmp-1685592358.26-1767-102413995694194/AnsiballZ_ping.py", from ansible.module_utils import basic File "<frozen zipimport>", line 241, in load_module File "<frozen zipimport>", line 709, in _get_module_code File "<frozen zipimport>", line 570, in _get_data zipimport.ZipImportError: can't decompress data; zlib not available [WARNING]: Platform linux on host 192.168.139.147 is using the discovered Python interpreter future installation of another Python interpreter could change this. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more 192.168.139.147 | FAILED! => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": false, "module_stderr": "Shared connection to 192.168.139.147 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"<frozen zipimport>\", liunc\r\nModuleNotFoundError: No module named 'zlib'\r\n\r\nDuring handling of the above exceptred:\r\n\r\nTraceback (most recent call last):\r\n File \"<frozen zipimport>\", line 568, inen zipimport>\", line 523, in _get_decompress_func\r\nzipimport.ZipImportError: can't decompr\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback File \"/root/.ansible/tmp/ansible-tmp-1685592358.26-1767-102413995694194/AnsiballZ_ping.py\ _ansiballz_main()\r\n File \"/root/.ansible/tmp/ansible-tmp-1685592358.26-1767-102413995line 94, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\nansible-tmp-1685592358.26-1767-102413995694194/AnsiballZ_ping.py\", line 37, in invoke_moduleutils import basic\r\n File \"<frozen zipimport>\", line 241, in load_module\r\n File \"<fr in _get_module_code\r\n File \"<frozen zipimport>\", line 570, in _get_data\r\nzipimport.Ziss data; zlib not available\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1 }
缺少zlib模块,由于apt安装过程中无法安装python3.8,所以我们有理由怀疑zlib也无法通过apt安装的,或许可以pip安装,但是源码编译过程中我们没有安装pip,所以害得安装pip(生气),但是安装pip过程中缺少了zlib,,所以重新源码编译一次
./configure --with-zlib
make altinstall
就ok了
后续补充:
wget https://bootstrap.pypa.io/get-pip.py
python3.8 get-pip.py
pip3.8 --version
浙公网安备 33010602011771号