I’m experimenting with some Ansible playbooks against local VMs, in particular, for some reason a RHEL 8 VM, and getting some unitelligible errors:
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_z3bjr2pn/ansible_ansible.legacy.setup_payload.zip/ansible/module_utils/basic.py\", line 5\r\nSyntaxError: future feature annotations is not defined\r\n", "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error", "rc": 1}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}
Googling for various parts of this error, I think the key error is:
SyntaxError: future feature annotations is not defined
… as this shows up in a few posts, and in particular this excellent post by Jeff Geerling that explains exactly what is going on with Python version incompatibilities between later versions of Ansible and RHEL 8 (which uses an older version of Python, 3.7)
Ansible version on my Mac:
❯ ansible-playbook --version
ansible-playbook [core 2.18.6]
Downgrading to Ansible 9x with brew:
❯ brew install ansible@9
==> Fetching downloads for: ansible@9
Warning: ansible@9 has been deprecated because it is not maintained upstream! It will be disabled on 2025-11-30
For personal projects this is not much of a big deal, and I don’t think I’m particularly taking advantage of any newer Ansible features, but bit of a version dependency nightmare.
Now I get:
❯ ansible --version
ansible [core 2.16.14]
… and can successfully apply playbooks against my RHEL 8 VM.
