Skip to content

Commit 7a99665

Browse files
committed
Allow to avoid installing the libvirt daemon and/or client
This may be useful where we want to use an existing libvirt daemon.
1 parent c2dc3ba commit 7a99665

File tree

8 files changed

+50
-7
lines changed

8 files changed

+50
-7
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

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)