Reputation: 61
I'm unable to ping the another server. And i have SSH communication also authenticated. Please find the below error
ansible all -m ping -u ubuntu -i inventory
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
}
Upvotes: 0
Views: 7900
Reputation: 187
Seems like ansible is not able to find python distribution in the client.
The simplest solution is to tell ansible where to find it in ansible.cfg
. Just add:
[defaults]
...
interpreter_python = <pyhton path in client>
the python path in the client can be found by running:
which python
or for newer versions (recommended for ansible):
which python3
like so:
in most modern Debian based distributions, python is located at /usr/bin/python3
that makes the final solution:
[defaults]
...
interpreter_python = /usr/bin/python3
Upvotes: 0
Reputation: 329
I have got the similar error and resolved it.
After creating the container I used the following command to install python on it:
apt-get install python-minimal --no-install-recommends
But, when i got the "ImportError: No module named zipfile" error with ansible ping command, I just got into the container (with lxc-attach) and used:
apt-get install python
And then my ansible ping command worked as expected.
Upvotes: 0
Reputation: 7214
Prasanna, go to 10.0.3.128 run python, and try to :
import zipfile
It seems like either it wasn't compiled with it or it can't find the library so maybe an environment issue. try it as the ansible user
Upvotes: 1