Skip to content

Commit 01f0974

Browse files
authored
Merge pull request #3 from stackhpc/support-qemu
Support qemu
2 parents a2e6128 + c35624b commit 01f0974

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ should be a dict containing the following items:
3030
supported.
3131
- `bridge` The name of the bridge interface for this network.
3232

33+
`libvirt_host_require_vt`is whether to require that Intel Virtualisation
34+
Technology (VT) is enabled in order to run this role. While this provides
35+
better VM performance, it may not be available in certain environments. The
36+
default value is `true`.
37+
38+
`libvirt_host_qemu_emulators`: List of architectures for which to install QEMU
39+
system emulators, e.g. `x86`. The default value is `['x86']` if
40+
`libvirt_host_require_vt` is `false`, otherwise the default value is an empty
41+
list.
42+
3343
Dependencies
3444
------------
3545

defaults/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@ libvirt_host_pools: []
1717
# supported.
1818
# bridge: The name of the bridge interface for this network.
1919
libvirt_host_networks: []
20+
21+
# Whether to require that Intel Virtualisation Technology (VT) is enabled in
22+
# order to run this role. While this provides better VM performance, it may not
23+
# be available in certain environments.
24+
libvirt_host_require_vt: true
25+
26+
# List of architectures for which to install QEMU system emulators, e.g. x86.
27+
libvirt_host_qemu_emulators: "{{ [] if libvirt_host_require_vt | bool else ['x86'] }}"

tasks/install.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@
1111
- qemu-kvm
1212
become: True
1313

14+
# NOTE: QEMU emulators are available in EPEL.
15+
- name: Ensure the EPEL repository is enabled
16+
yum:
17+
name: epel-release
18+
state: installed
19+
when: libvirt_host_qemu_emulators | length > 0
20+
become: True
21+
22+
- name: Ensure QEMU emulator packages are installed
23+
yum:
24+
name: "{{ package }}"
25+
state: installed
26+
with_items: "{{ libvirt_host_qemu_emulators }}"
27+
become: True
28+
vars:
29+
package: "qemu-system-{{ item }}"
30+
1431
- name: Ensure the libvirt daemon is started and enabled
1532
service:
1633
name: libvirtd

tasks/validate.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,24 @@
55
failed_when: False
66
register: result
77

8+
- name: Set a fact about whether Virtualization Technology (VT) is enabled
9+
set_fact:
10+
libvirt_host_vt_enabled: "{{ result.rc == 0 }}"
11+
12+
- name: Notify if Virtualization Technology (VT) is disabled
13+
debug:
14+
msg: >
15+
Virtualization Technology (VT) is currently disabled. Please enable VT
16+
before running this role again.
17+
when:
18+
- not libvirt_host_require_vt | bool
19+
- not libvirt_host_vt_enabled
20+
821
- name: Fail if Virtualization Technology (VT) is disabled
922
fail:
1023
msg: >
1124
Virtualization Technology (VT) is currently disabled. Please enable VT
1225
before running this role again.
13-
when: result.rc != 0
26+
when:
27+
- libvirt_host_require_vt | bool
28+
- not libvirt_host_vt_enabled

0 commit comments

Comments
 (0)