# Issue with Ansible on Rocky Linux 8.10 (Python 3.12) – "future feature annotations is not defined"

**URL:** <https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117>\
**Category:** Get Help\
**Tags:** centos, rockylinux\
**Created:** [March 19, 2025, 8:09am UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117 "2025-03-19T08:09:31Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jey\_Toled](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jey_toled/32/7926_2.png) [@Jey\_Toled](https://forum.ansible.com/u/Jey_Toled)\
**Post date:** [March 19, 2025, 8:09am UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/1 "2025-03-19T08:09:31Z")

</div>

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:

```auto
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:**

1. Create a virtual environment with Python 3.12:

```auto
python3.12 -m venv ansible312venv
source ansible312venv/bin/activate

```

1. Install different versions of Ansible:

```auto
pip install ansible==11.1.0 # Also tested with 10.7 and 9.7

```

1. Run the playbook:

```auto
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!

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 19, 2025, 2:29pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/2 "2025-03-19T14:29:50Z")

</div>

ansible-core 2.17 and newer do not support the default system python 3.6. I know you mention python3.12, however the `dnf` module requires the python dnf/rpm/gpgme/etc bindings, which are only packaged for the system python.

We have a feature called “respawn” which will attempt to respawn the module being executed, against known system python versions if the python bindings are missing from the python version specified by `ansible_python_interpreter`.

As such, in order for the `dnf` module to potentially work, it has to respawn on an interpreter that supports the python bindings it requires.

We’ve recently improved the method in which the other python interpreters are polled for respawn, to omit python versions that we no longer support. But that only cleans up the messaging on the failure to run the module.

So long story short, ansible-core 2.17+ simply cannot perform package related tasks against RHEL8. There are other modules in other collections that also won’t work as well due to this limitation.

---

<div class="post-metadata">

**Author:** ![jghal](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jghal/32/8174_2.png) [@jghal](https://forum.ansible.com/u/jghal)\
**Post date:** [April 18, 2025, 9:03pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/3 "2025-04-18T21:03:29Z")

</div>

> So long story short, ansible-core 2.17+ simply cannot perform package related tasks against RHEL8.

I’m having trouble accepting this the end of the discussion given that RedHat owns Ansible. Is there any kind of roadmap or plan for resolving this?

---

<div class="post-metadata">

**Author:** ![anon81884396](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon81884396](https://forum.ansible.com/u/anon81884396)\
**Post date:** [April 18, 2025, 10:15pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/4 "2025-04-18T22:15:15Z")

</div>

RedHat has lifecycles for its software leaving supportability, Python 3.6’s end of life was in 2021. Not sure what kind of discussion remains to be had.

---

<div class="post-metadata">

**Author:** ![jghal](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jghal/32/8174_2.png) [@jghal](https://forum.ansible.com/u/jghal)\
**Post date:** [April 18, 2025, 10:21pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/5 "2025-04-18T22:21:15Z")

</div>

Ansible 2.16 and 2.17 go EOL this year. Is the official stance from RedHat to continue using the EOL Ansible 2.16 for the remaining life of RHEL 8?

---

<div class="post-metadata">

**Author:** ![anon81884396](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@anon81884396](https://forum.ansible.com/u/anon81884396)\
**Post date:** [April 18, 2025, 10:34pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/6 "2025-04-18T22:34:35Z")

</div>

Don’t know if I’ve ever seen an official RedHat person ever post here, even the open source project maintainers have been scarce since last summer. Might be more productive to open a ticket with RH and get their stance that way

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [April 21, 2025, 3:08pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/7 "2025-04-21T15:08:13Z")

</div>

You may want to check this response for more detailed information:

> [@Python 3.7+ Impact on EL8 (future for EL9)](https://forum.ansible.com/t/python-3-7-impact-on-el8-future-for-el9/6229/13):
>
> I’ve held off on posting, largely because this is super complex problem. One we haven’t felt we’ve had a perfect solution for going on years now. This topic consumes an inordinate amount of engineering time continuously trying meet the needs of users, while simultaneously acknowledging our engineering limitations. Each year, or multiple times a year we think we’ve come to a concensus, and rinse and repeat. Hopefully with what we’ve learned and past things we’ve done, we continue to get better, b…

However, the long story short is the response I provided above, with the exception that Red Hat customers get extended critical security support for ansible-core 2.14 and ansible-core 2.16.

---

<div class="post-metadata">

**Author:** ![Kound](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kound/32/10738_2.png) [@Kound](https://forum.ansible.com/u/Kound)\
**Post date:** [May 16, 2026, 4:21am UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/8 "2026-05-16T04:21:17Z")

</div>

I ran into the same wall and built a solution hopefully worth sharing here.

The issue is a genuine incompatibility with no clean official fix: ansible-core \>= 2.17 needs Python 3.10+ on the managed host, but `python3-dnf` on EL8 tops out at Python 3.9. The `respawn` mechanism that’s supposed to handle this fails because the respawned interpreter (3.6) doesn’t satisfy ansible-core 2.17’s own `from __future__ import annotations` requirement.

I built `carlijoy.compat` — a collection that backports the original `ansible.builtin.dnf` from ansible-core 2.15 as a self-contained executable that runs under `/usr/libexec/platform-python` (the EL8 system Python with dnf bindings). The module interface is identical to `ansible.builtin.dnf`.

```bash
pip install ansible-el-compat
# or
ansible-galaxy collection install carlijoy.compat

```

```yaml
# Before
- ansible.builtin.dnf:
    name: httpd
    state: present

# After
- carlijoy.compat.dnf:
    name: httpd
    state: present

```

Repo: [GitHub - CarliJoy/ansible-el-compat: EL8-compatible Ansible modules for ansible-core \>= 2.17 · GitHub](https://github.com/CarliJoy/ansible-el-compat)

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [May 16, 2026, 7:05am UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/9 "2026-05-16T07:05:44Z")

</div>

ansible-core 2.21’s `dnf` module should also work with Rocky Linux and RHEL 8: [Support core packaging operations against older python versions by sivel · Pull Request #86432 · ansible/ansible · GitHub](https://github.com/ansible/ansible/pull/86432)

---

<div class="post-metadata">

**Author:** ![Kound](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kound/32/10738_2.png) [@Kound](https://forum.ansible.com/u/Kound)\
**Post date:** [May 16, 2026, 5:42pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/10 "2026-05-16T17:42:46Z")

</div>

That’s awesome. Thanks for the reference.  
Maybe someone could update: [Incompatibility of ansible.builtin.dnf Module with Newer Python Versions Due to python3-dnf Dependency in Ansible Automation Platform. - Red Hat Customer Portal](https://access.redhat.com/solutions/7127467) ?

---

<div class="post-metadata">

**Author:** ![mirabilos](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mirabilos/32/9721_2.png) [@mirabilos](https://forum.ansible.com/u/mirabilos)\
**Post date:** [July 14, 2026, 7:05pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/11 "2026-07-14T19:05:41Z")

</div>

Hmm, that will work… until you run into the next module that requires a system library.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [July 14, 2026, 9:21pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/12 "2026-07-14T21:21:03Z")

</div>

> [@mirabilos](#):
>
> Hmm, that will work… until you run into the next module that requires a system library

That is correct, modules needing this functionality will have to be updated to follow this same pattern.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [July 15, 2026, 5:36am UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/13 "2026-07-15T05:36:49Z")

</div>

@sivel is it possible for collections to use this while still supporting ansible-core 2.20 and before? Or do you need to do tricks such as two different modules, and an action plugin which selects one of the two modules according to which ansible-core version is in use?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [July 15, 2026, 2:51pm UTC](https://forum.ansible.com/t/issue-with-ansible-on-rocky-linux-8-10-python-3-12-future-feature-annotations-is-not-defined/41117/14 "2026-07-15T14:51:36Z")

</div>

I imagine a try/except for ImportError on the embed manager with a separate code path that could just import the separate file should work on older versions. I’ve not tried it, but I see no reason it would not work.
