Skip to content

Commit c35624b

Browse files
committed
Add support for installing QEMU emulators
Set the libvirt_host_qemu_emulators to a list of architectures for which to install QEMU system emulators.
1 parent 51decbd commit c35624b

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ Technology (VT) is enabled in order to run this role. While this provides
3434
better VM performance, it may not be available in certain environments. The
3535
default value is `true`.
3636

37+
`libvirt_host_qemu_emulators`: List of architectures for which to install QEMU
38+
system emulators, e.g. `x86`. The default value is `['x86']` if
39+
`libvirt_host_require_vt` is `false`, otherwise the default value is an empty
40+
list.
41+
3742
Dependencies
3843
------------
3944

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ libvirt_host_networks: []
2222
# order to run this role. While this provides better VM performance, it may not
2323
# be available in certain environments.
2424
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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@
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+
812
- name: Notify if Virtualization Technology (VT) is disabled
913
debug:
1014
msg: >
1115
Virtualization Technology (VT) is currently disabled. Please enable VT
1216
before running this role again.
1317
when:
1418
- not libvirt_host_require_vt | bool
15-
- result.rc != 0
19+
- not libvirt_host_vt_enabled
1620

1721
- name: Fail if Virtualization Technology (VT) is disabled
1822
fail:
@@ -21,4 +25,4 @@
2125
before running this role again.
2226
when:
2327
- libvirt_host_require_vt | bool
24-
- result.rc != 0
28+
- not libvirt_host_vt_enabled

0 commit comments

Comments
 (0)