Problems with Ansible/Python after last update

After last system update I’ve got a problems with running ansible. Description of a problem (will paste it below) points to problems with Python.
Local versions:

 - ansible core 2.17.0
 - python version = 3.12.3
 - jinja version = 3.1.3

I use Manjaro on my PC and laptop. So I installed updates first on PC and faced problems, while laptop had previous version of ansible (unfortunately I didn’t save version) with same version of python and everything works perfect.
At the end of a day I’ve install updates on laptop too and start to face same problems with ansible/python. Now I have both systems with same problem… :slight_smile:

Error log:

{
  "ansible.legacy.setup": {
    "ansible_facts": {
      "discovered_interpreter_python": "/usr/bin/python3"
    },
    "exception": "Traceback (most recent call last):\r\n  File \"/home/osp-admin/.ansible/tmp/ansible-tmp-1717068157.1190922-26108-232864809873690/AnsiballZ_setup.py\", line 107, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/osp-admin/.ansible/tmp/ansible-tmp-1717068157.1190922-26108-232864809873690/AnsiballZ_setup.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/osp-admin/.ansible/tmp/ansible-tmp-1717068157.1190922-26108-232864809873690/AnsiballZ_setup.py\", line 44, in invoke_module\r\n    from ansible.module_utils import basic\r\n  File \"<frozen importlib._bootstrap>\", line 971, in _find_and_load\r\n  File \"<frozen importlib._bootstrap>\", line 951, in _find_and_load_unlocked\r\n  File \"<frozen importlib._bootstrap>\", line 894, in _find_spec\r\n  File \"<frozen importlib._bootstrap_external>\", line 1157, in find_spec\r\n  File \"<frozen importlib._bootstrap_external>\", line 1131, in _get_spec\r\n  File \"<frozen importlib._bootstrap_external>\", line 1112, in _legacy_get_spec\r\n  File \"<frozen importlib._bootstrap>\", line 441, in spec_from_loader\r\n  File \"<frozen importlib._bootstrap_external>\", line 544, in spec_from_file_location\r\n  File \"/tmp/ansible_ansible.legacy.setup_payload_03yi8pil/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/basic.py\", line 5\r\nSyntaxError: future feature annotations is not defined\r\n",
    "failed": true,
    "module_stderr": "Shared connection to *(some builder host)* closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/osp-admin/.ansible/tmp/ansible-tmp-1717068157.1190922-26108-232864809873690/AnsiballZ_setup.py\", line 107, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/osp-admin/.ansible/tmp/ansible-tmp-1717068157.1190922-26108-232864809873690/AnsiballZ_setup.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/osp-admin/.ansible/tmp/ansible-tmp-1717068157.1190922-26108-232864809873690/AnsiballZ_setup.py\", line 44, in invoke_module\r\n    from ansible.module_utils import basic\r\n  File \"<frozen importlib._bootstrap>\", line 971, in _find_and_load\r\n  File \"<frozen importlib._bootstrap>\", line 951, in _find_and_load_unlocked\r\n  File \"<frozen importlib._bootstrap>\", line 894, in _find_spec\r\n  File \"<frozen importlib._bootstrap_external>\", line 1157, in find_spec\r\n  File \"<frozen importlib._bootstrap_external>\", line 1131, in _get_spec\r\n  File \"<frozen importlib._bootstrap_external>\", line 1112, in _legacy_get_spec\r\n  File \"<frozen importlib._bootstrap>\", line 441, in spec_from_loader\r\n  File \"<frozen importlib._bootstrap_external>\", line 544, in spec_from_file_location\r\n  File \"/tmp/ansible_ansible.legacy.setup_payload_03yi8pil/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/basic.py\", line 5\r\n**SyntaxError: future feature annotations is not defined**\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1,
    "warnings": [
      "Platform linux on host environment_host is using the discovered Python interpreter at /usr/bin/python3, but future installation of another Python interpreter could change the meaning of that path. See https://docs.ansible.com/ansible-core/2.17/reference_appendices/interpreter_discovery.html for more information."
    ]
  }
}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"
}

I did research for this error (SyntaxError: future feature annotations is not defined), and everything points to problem with python.
Was trying to configure python’s intepreter in ansible.cfg, but without success.

Remote builder host has these versions:

ansible 2.9.10
python version = 2.7.5

But as I said, before last update, everything work as a charm.

I don’t know anything about ansible but this Python version is horribly outdated. Update to Python 3 as soon as possible.

Python 2 has been no more since 4.5 years - you need to migrate your work

The sunset date has now passed; it was January 1st, 2020.
Sunsetting Python 2 | Python.org

Thank to all for advice to update python on a remote host. I would do this, but unfortunately team members afraid to break building environment for others.
As for now, I’ve solved it by downgrade related packages with manjaro-downgrade and it works again…
List of packages that have been updated and then downgraded to solve the problem, is below:

[2024-05-30T09:26:58+0300] [ALPM] upgraded python-trove-classifiers (2024.4.10-1 -> 2024.5.22-1)
[2024-05-30T09:26:58+0300] [ALPM] upgraded python-pyqt6 (6.7.0-2 -> 6.7.0-3)
[2024-05-30T09:26:57+0300] [ALPM] upgraded python-openstacksdk (3.0.0-2 -> 3.1.0-1)
[2024-05-30T09:26:57+0300] [ALPM] upgraded python-lxml (5.1.0-3 -> 5.2.2-1)
[2024-05-30T09:26:57+0300] [ALPM] upgraded python-dnspython (1:2.5.0-2 -> 1:2.6.1-1)
[2024-05-30T09:26:57+0300] [ALPM] upgraded python-boto3 (1.34.69-1 -> 1.34.106-1)
[2024-05-30T09:26:57+0300] [ALPM] upgraded python-botocore (1.34.69-1 -> 1.34.106-1)
[2024-05-30T09:26:57+0300] [ALPM] upgraded python-jmespath (1.0.1-3 -> 1.0.1-4)
[2024-05-30T09:26:57+0300] [ALPM] upgraded python-argcomplete (3.1.1-2 -> 3.1.1-3)
[2024-05-30T09:26:57+0300] [ALPM] upgraded python-annotated-types (0.6.0-3 -> 0.7.0-1)

[2024-05-30T09:26:21+0300] [ALPM] upgraded ansible (9.5.1-1 -> 9.6.0-2)
[2024-05-30T09:26:16+0300] [ALPM] upgraded ansible-core (2.16.6-3 -> 2.17.0-1)
[2024-05-30T09:26:15+0300] [ALPM] upgraded python-typing_extensions (4.11.0-1 -> 4.12.0-1)
[2024-05-30T09:26:15+0300] [ALPM] upgraded python-packaging (23.2-3 -> 24.0-1)
[2024-05-30T09:26:15+0300] [ALPM] upgraded python-cryptography (42.0.5-2 -> 42.0.6-1)

Depending on what outdated distribution you’re running on the host, you can install the two python versions accordingly, and then use python3 in your scripts, rather then plain python.

We don’t use any python scripts at all. We use only ansible and it uses python inside.
I’ll try to check work between local and remote hosts, with latest ansible and python versions later.