We have new control node, which has python 3.12 and ansible 2.18. [user@ansible-controller ~]$ ansible --version ansible [core 2.18.5] config file = None configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /opt/ansible-venv/lib64/python3.12/site-packages/ansible ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible python version = 3.12.8 (main, Dec 9 2024, 15:25:01) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/opt/ansible-venv/bin/python3.12) jinja version = 3.1.6 libyaml = True We set password less access for the target host [user@ansible-controller ~]$ ssh 10.10.10.2 Last login: Mon May 12 12:29:04 2025 from 10.10.10.1 $ python --version Python 2.7.5 $ which python /usr/bin/python $ exit Connection to 10.10.10.2 closed. 10.10.10.1 is control node which has python3 and 10.10.10.2 is target host which has python2. When we try to ping this host, it gives error. [user@ansible-controller ~]$ ansible -i 10.10.10.2, all -m ping [WARNING]: No python interpreters found for host 10.10.10.2 (tried ['python3.13', 'python3.12', 'python3.11', 'python3.10', 'python3.9', 'python3.8', '/usr/bin/python3', 'python3']) 10.10.10.2 | FAILED! => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "module_stderr": "Shared connection to 10.10.10.2 closed.\r\n", "module_stdout": "/bin/sh: /usr/bin/python3: No such file or directory\r\n", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127 } [user@ansible-controller ~]$ ansible -i 10.10.10.2, all -m ping -e "ansible_python_interpreter=/usr/bin/python" An exception occurred during task execution. To see the full traceback, use -vvv. The error user: SyntaxError: invalid syntax 10.10.10.2 | FAILED! => { "changed": false, "module_stderr": "Shared connection to 10.10.10.2 closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1747033142.7797244-89837-73942475506869/AnsiballZ_ping.py\", line 107, in <module>\r\n _ansiballz_main()\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1747033142.7797244-89837-73942475506869/AnsiballZ_ping.py\", line 99, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/home/user/.ansible/tmp/ansible-tmp-1747033142.7797244-89837-73942475506869/AnsiballZ_ping.py\", line 44, in invoke_module\r\n from ansible.module_utils import basic\r\n File \"/tmp/ansible_ping_payload_F4fKJc/ansible_ping_payload.zip/ansible/module_utils/basic.py\", line 17\r\n msg=f\"ansible-core requires a minimum of Python version {'.'.join(map(str, _PY_MIN))}. Current version: {''.join(sys.version.splitlines())}\",\r\n ^\r\nSyntaxError: invalid syntax\r\n", "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error", "rc": 1 } its giving SyntaxError: invalid syntax, I have doubt, that this version of ansible has syntax error in code or its due to python3 -> python2 combination? Continue reading...