Skip to content

Support qemu #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------

Expand Down
8 changes: 8 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }}"
17 changes: 17 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion tasks/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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