diff --git a/tasks/yumrepos.yml b/tasks/yumrepos.yml index 36ed0b2cf6..43a47fc181 100644 --- a/tasks/yumrepos.yml +++ b/tasks/yumrepos.yml @@ -148,3 +148,19 @@ - config - packages - yumrepos + +# when batcave01 is on a newer ansible we won't need python3-dnf but +# we *will* need python3-rpm (package_facts fails without it) +- name: Ensure that python3-dnf is installed (needed till ansible on batcave01 supports dnf5) + when: "ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 40 and ansible_cmdline.ostree is not defined" + block: + - name: Check whether python3-dnf is installed + ansible.builtin.command: "rpm -q python3-dnf" + register: p3dnf + failed_when: "1 != 1" + changed_when: "1 != 1" + check_mode: no + + - name: Install python3-dnf with direct dnf command + ansible.builtin.command: "dnf -y install python3-dnf" + when: "p3dnf.rc != 0"