From a7427a83ef82afb4eeaa0752f62e95870941c280 Mon Sep 17 00:00:00 2001 From: Michal Nasiadka Date: Wed, 19 Jun 2024 13:32:02 +0200 Subject: [PATCH] Install ovmf on Ubuntu when EFI VM is requested --- tasks/main.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index ebeb806..f9dd247 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,9 +16,17 @@ | selectattr('state', 'equalto', 'absent') | list) != libvirt_vms # Libvirt requires qemu-img to create qcow2 files. -- name: Ensure qemu-img is installed +- name: Ensure qemu-img and ovmf is installed + vars: + is_efi: >- + (libvirt_vms | selectattr('state', 'defined') + | selectattr('state', 'equalto', 'absent') | + | selectattr('boot_firmware', 'equalto', 'efi')) | bool + packages: + - "{{ 'qemu-img' if ansible_facts.os_family == 'RedHat' else 'qemu-utils' }}" + - "{{ 'ovmf' if ansible_facts.os_family == 'Debian' and is_efi }}" ansible.builtin.package: - name: "{{ 'qemu-img' if ansible_facts.os_family == 'RedHat' else 'qemu-utils' }}" + name: "{{ packages | select | unique | list }}" update_cache: "{{ True if ansible_facts.pkg_mgr == 'apt' else omit }}" become: true