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.