diff --git a/README.md b/README.md index da907d8..d310672 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,16 @@ should be a dict containing the following items: supported. - `bridge` The name of the bridge interface for this network. +`libvirt_host_require_vt`is whether to require that Intel Virtualisation +Technology (VT) is enabled in order to run this role. While this provides +better VM performance, it may not be available in certain environments. The +default value is `true`. + +`libvirt_host_qemu_emulators`: List of architectures for which to install QEMU +system emulators, e.g. `x86`. The default value is `['x86']` if +`libvirt_host_require_vt` is `false`, otherwise the default value is an empty +list. + Dependencies ------------ diff --git a/defaults/main.yml b/defaults/main.yml index 25d3e13..aea4159 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,3 +17,11 @@ libvirt_host_pools: [] # supported. # bridge: The name of the bridge interface for this network. libvirt_host_networks: [] + +# Whether to require that Intel Virtualisation Technology (VT) is enabled in +# order to run this role. While this provides better VM performance, it may not +# be available in certain environments. +libvirt_host_require_vt: true + +# List of architectures for which to install QEMU system emulators, e.g. x86. +libvirt_host_qemu_emulators: "{{ [] if libvirt_host_require_vt | bool else ['x86'] }}" diff --git a/tasks/install.yml b/tasks/install.yml index 16898b1..5b457d0 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -11,6 +11,23 @@ - qemu-kvm become: True +# NOTE: QEMU emulators are available in EPEL. +- name: Ensure the EPEL repository is enabled + yum: + name: epel-release + state: installed + when: libvirt_host_qemu_emulators | length > 0 + become: True + +- name: Ensure QEMU emulator packages are installed + yum: + name: "{{ package }}" + state: installed + with_items: "{{ libvirt_host_qemu_emulators }}" + become: True + vars: + package: "qemu-system-{{ item }}" + - name: Ensure the libvirt daemon is started and enabled service: name: libvirtd diff --git a/tasks/validate.yml b/tasks/validate.yml index e0af95e..ed613be 100644 --- a/tasks/validate.yml +++ b/tasks/validate.yml @@ -5,9 +5,24 @@ failed_when: False register: result +- name: Set a fact about whether Virtualization Technology (VT) is enabled + set_fact: + libvirt_host_vt_enabled: "{{ result.rc == 0 }}" + +- name: Notify if Virtualization Technology (VT) is disabled + debug: + msg: > + Virtualization Technology (VT) is currently disabled. Please enable VT + before running this role again. + when: + - not libvirt_host_require_vt | bool + - not libvirt_host_vt_enabled + - name: Fail if Virtualization Technology (VT) is disabled fail: msg: > Virtualization Technology (VT) is currently disabled. Please enable VT before running this role again. - when: result.rc != 0 + when: + - libvirt_host_require_vt | bool + - not libvirt_host_vt_enabled