guest-setup: fix `ansible_pkg_mgr` detection on Fedora ELN with Ansible 2.16

Ansible 2.16 incorrectly detects ansible_pkg_mgr as yum on Fedora ELN, even though /usr/bin/yum and /usr/bin/dnf are symlinks to /usr/bin/dnf5. This causes the package module to delegate to the yum module which fails with "The Python 2 yum module is needed for this module."

Since set_fact cannot override gathered facts in the ansible_facts dict, the fix uses module_defaults on the ansible.builtin.package module with a _pkg_module variable that is conditionally set to dnf5 on Fedora when ansible_pkg_mgr is incorrectly detected as yum. No supported Fedora release uses yum, so this override is always safe. Ansible 2.18+ correctly detects dnf5.

Also add debug output for ansible_pkg_mgr before and after the override for easier troubleshooting.

Resolves: TFT-4628 Assisted-by: Claude Code

Edited by Miroslav Vadkerti

Merge request reports

Loading
Loading