Skip to content

Commit 05a3470

Browse files
authored
Merge pull request #44 from stackhpc/allow-skip-install
Allow to avoid installing the libvirt daemon and/or client
2 parents c2dc3ba + 3f1e2cc commit 05a3470

File tree

9 files changed

+71
-18
lines changed

9 files changed

+71
-18
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ the virt_ ansible modules.
8585
bindings should be installed. If `false`, the python 2 bindings will be
8686
installed.
8787

88+
`libvirt_host_install_daemon`: Whether to install and enable the libvirt
89+
daemon. Default is `true`.
90+
91+
`libvirt_host_install_client`: Whether to install and enable the libvirt
92+
client. Default is `true`.
93+
8894
Dependencies
8995
------------
9096

defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,9 @@ libvirt_host_uri: >-
6767
# Whether the python3 version of the libvirt python bindings should be
6868
# installed. If false, the python 2 bindings will be installed.
6969
libvirt_host_python3: "{{ ansible_python.version.major == 3 }}"
70+
71+
# Whether to install and enable the libvirt daemon.
72+
libvirt_host_install_daemon: true
73+
74+
# Whether to install and enable the libvirt client.
75+
libvirt_host_install_client: true

tasks/install-client.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
- name: Ensure libvirt client packages are installed
3+
package:
4+
name: "{{ libvirt_host_libvirt_packages_client }}"
5+
state: present
6+
register: result
7+
until: result is success
8+
retries: 3
9+
become: True
File renamed without changes.

tasks/main.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
---
22
- include: prelude.yml
33
- include: validate.yml
4-
- include: install.yml
4+
- include: install-daemon.yml
5+
when: libvirt_host_install_daemon | bool
6+
- include: install-client.yml
7+
when:
8+
- not libvirt_host_install_daemon | bool
9+
- libvirt_host_install_client | bool
510
- name: Run post-install stage
611
include: "{{ post_install_path }}"
712
with_first_found:
@@ -12,5 +17,6 @@
1217
loop_control:
1318
loop_var: post_install_path
1419
- include: config.yml
20+
when: libvirt_host_install_daemon | bool
1521
- include: pools.yml
1622
- include: networks.yml

tasks/pools.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
11
---
2-
- name: Ensure libvirt dir storage pool directories exist
3-
file:
4-
path: "{{ item.path }}"
5-
owner: "{{ item.owner }}"
6-
group: "{{ item.group }}"
7-
mode: "{{ item.mode|int(base=8) }}"
8-
state: directory
9-
when: item.type == "dir"
10-
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
11-
become: True
12-
132
- name: Ensure libvirt LVM storage pool directories exist
143
lvg:
154
vg: "{{ item.source }}"
@@ -34,6 +23,27 @@
3423
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
3524
become: True
3625

26+
- name: Check libvirt directory storage pool status
27+
virt_pool:
28+
name: "{{ item.name }}"
29+
command: status
30+
uri: "{{ libvirt_host_uri | default(omit, true) }}"
31+
when: item.type == "dir"
32+
loop: "{{ libvirt_host_pools | flatten(levels=1) }}"
33+
become: True
34+
register: pool_status
35+
36+
- name: Ensure libvirt directory storage pools are built
37+
virt_pool:
38+
name: "{{ item.item.name }}"
39+
command: build
40+
uri: "{{ libvirt_host_uri | default(omit, true) }}"
41+
when:
42+
- item is not skipped
43+
- item.status != "active"
44+
loop: "{{ pool_status.results }}"
45+
become: True
46+
3747
- name: Ensure libvirt storage pools are active
3848
virt_pool:
3949
name: "{{ item.name }}"

vars/Archlinux.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
libvirt_host_libvirt_packages_default:
44
- libvirt
55
- qemu-headless
6-
- libvirt-python
7-
- python-lxml
86
- ebtables
97
- dnsmasq
108

9+
# List of all client packages to install.
10+
libvirt_host_libvirt_packages_client:
11+
- libvirt
12+
- libvirt-python
13+
- python-lxml
14+
1115
# Packages that are only necessary if you require EFI support
1216
libvirt_host_packages_efi:
1317
- ovmf
1418

1519
# List of all packages to install
1620
libvirt_host_libvirt_packages: >
1721
{{ libvirt_host_libvirt_packages_default +
22+
libvirt_host_libvirt_packages_client +
1823
(libvirt_host_packages_efi if libvirt_host_enable_efi_support else []) | unique
1924
}}
2025

vars/Debian.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# List of package dependencies common to all Debian distributions
33
libvirt_host_libvirt_packages_common:
44
- qemu-kvm
5-
- "{{ 'python3-libvirt' if libvirt_host_python3 | bool else 'python-libvirt' }}"
6-
- "{{ 'python3-lxml' if libvirt_host_python3 | bool else 'python-lxml' }}"
75

86
# Package that contains the libvirt daemon
97
libvirt_host_libvirt_packages_libvirt_daemon: >-
@@ -16,13 +14,21 @@ libvirt_host_libvirt_packages_libvirt_daemon: >-
1614
libvirt-daemon-system
1715
{%- endif -%}
1816
17+
# List of all client packages to install.
18+
libvirt_host_libvirt_packages_client:
19+
- libvirt-clients
20+
- "{{ 'python3-libvirt' if libvirt_host_python3 | bool else 'python-libvirt' }}"
21+
- "{{ 'python3-lxml' if libvirt_host_python3 | bool else 'python-lxml' }}"
22+
1923
# Packages that are only necessary if you require EFI support
2024
libvirt_host_packages_efi:
2125
- ovmf
2226

2327
# List of all packages to install
2428
libvirt_host_libvirt_packages: >
25-
{{ libvirt_host_libvirt_packages_common + [libvirt_host_libvirt_packages_libvirt_daemon] +
29+
{{ libvirt_host_libvirt_packages_common +
30+
[libvirt_host_libvirt_packages_libvirt_daemon] +
31+
libvirt_host_libvirt_packages_client +
2632
(libvirt_host_packages_efi if libvirt_host_enable_efi_support else []) | unique
2733
}}
2834

vars/RedHat.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ libvirt_host_libvirt_packages_default:
88
- libgcrypt-devel
99
- libvirt
1010
- libvirt-daemon-kvm
11+
- qemu-kvm
12+
13+
# List of all client packages to install.
14+
libvirt_host_libvirt_packages_client:
15+
- libvirt-client
1116
- "{{ 'python3-libvirt' if libvirt_host_python3 | bool else 'libvirt-python' }}"
1217
- "{{ 'python3-lxml' if libvirt_host_python3 | bool else 'python-lxml' }}"
13-
- qemu-kvm
1418

1519
# Packages that are only necessary if you require EFI support
1620
libvirt_host_packages_efi:
@@ -20,6 +24,7 @@ libvirt_host_packages_efi:
2024
# List of all packages to install
2125
libvirt_host_libvirt_packages: >
2226
{{ libvirt_host_libvirt_packages_default +
27+
libvirt_host_libvirt_packages_client +
2328
(libvirt_host_packages_efi if libvirt_host_enable_efi_support else []) | unique
2429
}}
2530

0 commit comments

Comments
 (0)