Hi everyone,
I’m encountering an issue while running Ansible on Rocky Linux 8.10 (Green Obsidian) with Python 3.12 in localhost. I tested different versions of Ansible within a virtual environment, using the same playbook each time. Here are my findings:
- Ansible 11.1.0 / Ansible-core 2.18 →
KO
- Ansible 10.7 / Ansible-core 2.17.7 →
KO
- Ansible 9.13.0 / Ansible-core 2.16.14 →
OK
For both failing cases, I get the following error when running my playbook:
TASK [setup_server : Install required packages on CentOS] *************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: SyntaxError: future feature annotations is not defined
fatal: [localhost]: FAILED! => changed=false
module_stderr: |-
Traceback (most recent call last):
File "<stdin>", line 12, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 951, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 894, in _find_spec
File "<frozen importlib._bootstrap_external>", line 1157, in find_spec
File "<frozen importlib._bootstrap_external>", line 1131, in _get_spec
File "<frozen importlib._bootstrap_external>", line 1112, in _legacy_get_spec
File "<frozen importlib._bootstrap>", line 441, in spec_from_loader
File "<frozen importlib._bootstrap_external>", line 544, in spec_from_file_location
File "/tmp/ansible_ansible.legacy.dnf_payload_p6gl3c4k/ansible_ansible.legacy.dnf_payload.zip/ansible/module_utils/basic.py", line 5
SyntaxError: future feature annotations is not defined
module_stdout: ''
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
Steps to reproduce:
- Create a virtual environment with Python 3.12:
python3.12 -m venv ansible312venv
source ansible312venv/bin/activate
- Install different versions of Ansible:
pip install ansible==11.1.0 # Also tested with 10.7 and 9.7
- Run the playbook:
ansible-playbook playbook.yml --tags server -vvv
It seems like Ansible-core 2.17+ is not working properly with Python 3.12 on Rocky Linux 8.10.
Has anyone else encountered this issue? Is there a known workaround or fix?
Thanks in advance!