Skip to content

Install ovmf on Ubuntu when EFI VM is requested #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be rejectattr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copy pasted the from L14, but you're right - we don't need to install ovmf if we only want to remove VMs (I would assume it's already installed then).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit tricky also because the default for state is present, but the first selectattr only looks for VMs with a state defined. I think you'd need to concatenate lists of state undefined and state = present. Or you could ignore this micro optimisation for the state.

| selectattr('boot_firmware', 'equalto', 'efi')) | bool

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this fail if boot_firmware is not defined for a VM? Based on L58 it should be optional.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It hasn't failed in Gerrit change - https://review.opendev.org/c/openstack/kayobe/+/921660

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because that change sets boot_firmware :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, a lot of | default(something) ;-)

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

Expand Down