Skip to content

Commit

Permalink
Merge pull request #44 from stackhpc/allow-skip-install
Browse files Browse the repository at this point in the history
Allow to avoid installing the libvirt daemon and/or client
  • Loading branch information
markgoddard authored Dec 16, 2020
2 parents c2dc3ba + 3f1e2cc commit 05a3470
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 18 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ the virt_ ansible modules.
bindings should be installed. If `false`, the python 2 bindings will be
installed.

`libvirt_host_install_daemon`: Whether to install and enable the libvirt
daemon. Default is `true`.

`libvirt_host_install_client`: Whether to install and enable the libvirt
client. Default is `true`.

Dependencies
------------

Expand Down
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ libvirt_host_uri: >-
# Whether the python3 version of the libvirt python bindings should be
# installed. If false, the python 2 bindings will be installed.
libvirt_host_python3: "{{ ansible_python.version.major == 3 }}"

# Whether to install and enable the libvirt daemon.
libvirt_host_install_daemon: true

# Whether to install and enable the libvirt client.
libvirt_host_install_client: true
9 changes: 9 additions & 0 deletions tasks/install-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Ensure libvirt client packages are installed
package:
name: "{{ libvirt_host_libvirt_packages_client }}"
state: present
register: result
until: result is success
retries: 3
become: True
File renamed without changes.
8 changes: 7 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
---
- include: prelude.yml
- include: validate.yml
- include: install.yml
- include: install-daemon.yml
when: libvirt_host_install_daemon | bool
- include: install-client.yml
when:
- not libvirt_host_install_daemon | bool
- libvirt_host_install_client | bool
- name: Run post-install stage
include: "{{ post_install_path }}"
with_first_found:
Expand All @@ -12,5 +17,6 @@
loop_control:
loop_var: post_install_path
- include: config.yml
when: libvirt_host_install_daemon | bool
- include: pools.yml
- include: networks.yml
32 changes: 21 additions & 11 deletions tasks/pools.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
---
- name: Ensure libvirt dir storage pool directories exist
file:
path: "{{ item.path }}"
owner: "{{ item.owner }}"
group: "{{ item.group }}"
mode: "{{ item.mode|int(base=8) }}"
state: directory
when: item.type == "dir"
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
become: True

- name: Ensure libvirt LVM storage pool directories exist
lvg:
vg: "{{ item.source }}"
Expand All @@ -34,6 +23,27 @@
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
become: True

- name: Check libvirt directory storage pool status
virt_pool:
name: "{{ item.name }}"
command: status
uri: "{{ libvirt_host_uri | default(omit, true) }}"
when: item.type == "dir"
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
become: True
register: pool_status

- name: Ensure libvirt directory storage pools are built
virt_pool:
name: "{{ item.item.name }}"
command: build
uri: "{{ libvirt_host_uri | default(omit, true) }}"
when:
- item is not skipped
- item.status != "active"
loop: "{{ pool_status.results }}"
become: True

- name: Ensure libvirt storage pools are active
virt_pool:
name: "{{ item.name }}"
Expand Down
9 changes: 7 additions & 2 deletions vars/Archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
libvirt_host_libvirt_packages_default:
- libvirt
- qemu-headless
- libvirt-python
- python-lxml
- ebtables
- dnsmasq

# List of all client packages to install.
libvirt_host_libvirt_packages_client:
- libvirt
- libvirt-python
- python-lxml

# Packages that are only necessary if you require EFI support
libvirt_host_packages_efi:
- ovmf

# List of all packages to install
libvirt_host_libvirt_packages: >
{{ libvirt_host_libvirt_packages_default +
libvirt_host_libvirt_packages_client +
(libvirt_host_packages_efi if libvirt_host_enable_efi_support else []) | unique
}}
Expand Down
12 changes: 9 additions & 3 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# List of package dependencies common to all Debian distributions
libvirt_host_libvirt_packages_common:
- qemu-kvm
- "{{ 'python3-libvirt' if libvirt_host_python3 | bool else 'python-libvirt' }}"
- "{{ 'python3-lxml' if libvirt_host_python3 | bool else 'python-lxml' }}"

# Package that contains the libvirt daemon
libvirt_host_libvirt_packages_libvirt_daemon: >-
Expand All @@ -16,13 +14,21 @@ libvirt_host_libvirt_packages_libvirt_daemon: >-
libvirt-daemon-system
{%- endif -%}
# List of all client packages to install.
libvirt_host_libvirt_packages_client:
- libvirt-clients
- "{{ 'python3-libvirt' if libvirt_host_python3 | bool else 'python-libvirt' }}"
- "{{ 'python3-lxml' if libvirt_host_python3 | bool else 'python-lxml' }}"

# Packages that are only necessary if you require EFI support
libvirt_host_packages_efi:
- ovmf

# List of all packages to install
libvirt_host_libvirt_packages: >
{{ libvirt_host_libvirt_packages_common + [libvirt_host_libvirt_packages_libvirt_daemon] +
{{ libvirt_host_libvirt_packages_common +
[libvirt_host_libvirt_packages_libvirt_daemon] +
libvirt_host_libvirt_packages_client +
(libvirt_host_packages_efi if libvirt_host_enable_efi_support else []) | unique
}}
Expand Down
7 changes: 6 additions & 1 deletion vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ libvirt_host_libvirt_packages_default:
- libgcrypt-devel
- libvirt
- libvirt-daemon-kvm
- qemu-kvm

# List of all client packages to install.
libvirt_host_libvirt_packages_client:
- libvirt-client
- "{{ 'python3-libvirt' if libvirt_host_python3 | bool else 'libvirt-python' }}"
- "{{ 'python3-lxml' if libvirt_host_python3 | bool else 'python-lxml' }}"
- qemu-kvm

# Packages that are only necessary if you require EFI support
libvirt_host_packages_efi:
Expand All @@ -20,6 +24,7 @@ libvirt_host_packages_efi:
# List of all packages to install
libvirt_host_libvirt_packages: >
{{ libvirt_host_libvirt_packages_default +
libvirt_host_libvirt_packages_client +
(libvirt_host_packages_efi if libvirt_host_enable_efi_support else []) | unique
}}
Expand Down

0 comments on commit 05a3470

Please sign in to comment.