- name: Install packages
  become: yes
  apt:
    state: latest
    install_recommends: false
    name:
      - qemu-kvm
      - qemu-system
      - qemu-utils
      - libvirt-daemon
      - libvirt-daemon-system
      - ovmf
      - virt-manager

- name: Ensure group "libvirt" exists
  become: yes
  ansible.builtin.group:
    name: libvirt
    state: present

- name: Add user to group "libvirt"
  become: yes
  ansible.builtin.user:
    name: "{{ ansible_user_id }}"
    state: present
    groups:
      - libvirt
    append: true