The following modules failed to execute: setup

Hi Team,

did anyone face this issue, it was working fine but today i am getting below error not sure what happened:

fatal: [localhost]: FAILED! => {
“ansible_facts”: {},
“changed”: false,
“failed_modules”: {
“setup”: {
“exception”: “Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1595260298.32-3449-114062721166446/AnsiballZ_setup.py", line 102, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-tmp-1595260298.32-3449-114062721166446/AnsiballZ_setup.py", line 20, in _ansiballz_main\n import tempfile\n File "/opt/rh/python27/root/usr/lib64/python2.7/tempfile.py", line 32, in \n import io as _io\n File "/opt/rh/python27/root/usr/lib64/python2.7/io.py", line 51, in \n import _io\nImportError: /opt/rh/python27/root/usr/lib64/python2.7/lib-dynload/_io.so: undefined symbol: _PyErr_ReplaceException\n”,
“failed”: true,
“module_stderr”: “Traceback (most recent call last):\n File "/root/.ansible/tmp/ansible-tmp-1595260298.32-3449-114062721166446/AnsiballZ_setup.py", line 102, in \n _ansiballz_main()\n File "/root/.ansible/tmp/ansible-tmp-1595260298.32-3449-114062721166446/AnsiballZ_setup.py", line 20, in _ansiballz_main\n import tempfile\n File "/opt/rh/python27/root/usr/lib64/python2.7/tempfile.py", line 32, in \n import io as _io\n File "/opt/rh/python27/root/usr/lib64/python2.7/io.py", line 51, in \n import _io\nImportError: /opt/rh/python27/root/usr/lib64/python2.7/lib-dynload/_io.so: undefined symbol: _PyErr_ReplaceException\n”,
“module_stdout”: “”,
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,
“rc”: 1
}
},
“msg”: “The following modules failed to execute: setup\n”
}

It sounds like you have a _io.so file that was compiled against a different python version, from that which is attempting to use it.

Using python from an SCL as your ansible_python_interpreter is not just an easy 1 and done, by using the correct path. An SCL sets things like LD_LIBRARY_PATH and such when you enable it, that is not achieved by simply calling the binary in its place.

It looks like you are using localhost, which I will assume is “implicit localhost”[1] which automatically selects the python interpreter used by the playbook process, but since that work happens in a fork, I imagine it loses the SCL env vars required to use that SCL.

Overall, I’d probably recommend not using an SCL. Otherwise, you are going to have to jump through some hoops that are going to require that you better understand what needs to be done.

[1] https://docs.ansible.com/ansible/latest/inventory/implicit_localhost.html

Hi Matt,

i have enabled the scl python27 and it worked, is this not recommended ?

scl enable python27 bash

i have installed the pip using below process:

https://access.redhat.com/solutions/1519803

Thanks and Regards
Nagesh