--- # ============================================================================= # Installation Tasks - Install Required Packages on Hypervisor # ============================================================================= - name: Install required packages for VM deployment (Debian/Ubuntu) apt: name: - libvirt-daemon-system - libvirt-clients - virtinst - qemu-kvm - qemu-utils - cloud-image-utils - genisoimage - wget - curl - python3-libvirt - lvm2 - parted state: present update_cache: yes when: ansible_os_family == "Debian" tags: [install] - name: Install required packages for VM deployment (RHEL/CentOS) dnf: name: - libvirt - libvirt-client - virt-install - qemu-kvm - qemu-img - cloud-utils - genisoimage - wget - curl - python3-libvirt - lvm2 - parted state: present when: ansible_os_family == "RedHat" tags: [install] - name: Ensure libvirtd service is running systemd: name: libvirtd state: started enabled: yes tags: [install] - name: Ensure default libvirt network is active command: virsh net-start default register: deploy_linux_vm_net_start failed_when: false changed_when: deploy_linux_vm_net_start.rc == 0 tags: [install] - name: Ensure default libvirt network is autostarted command: virsh net-autostart default register: deploy_linux_vm_net_autostart failed_when: false changed_when: false tags: [install]