AlmaLinux and “python3-dnf”

Martin is correct, you cannot use ansible-core>=2.17 with the yum/dnf modules on EL8 and older OS systems (RHEL/CentOS/Alma/Rocky, etc). The OS upgrade and alternatives configuration have nothing to do with it, and in fact shouldn’t have worked before the CentOS7 → AlmaLinux8 upgrade either.

@sivel has covered this topic extensively. He has a short but detailed explanation here: Issue with Ansible on Rocky Linux 8.10 (Python 3.12) – "future feature annotations is not defined" - #2 by sivel and a longer and more thorough explanation here: Python 3.7+ Impact on EL8 (future for EL9) - #13 by sivel