Skip to content

Commit 0b1459d

Browse files
committed
Add support for python 3 libvirt python bindings
This is controlled via libvirt_host_python3.
1 parent fa339a6 commit 0b1459d

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ init system when libvirtd is started - quotes will be added
7272
an explicit connection URI will not be set when calling virsh or any of
7373
the virt_ ansible modules.
7474

75+
`libvirt_host_python3`: Whether the python3 version of the libvirt python
76+
bindings should be installed. If `false`, the python 2 bindings will be
77+
installed.
78+
7579
Dependencies
7680
------------
7781

defaults/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ libvirt_host_uri: >-
6161
{%- if libvirt_host_socket_dir -%}
6262
qemu+unix:///system?socket={{ libvirt_host_socket_dir }}/libvirt-sock
6363
{%- endif %}
64+
65+
# Whether the python3 version of the libvirt python bindings should be
66+
# installed. If false, the python 2 bindings will be installed.
67+
libvirt_host_python3: >-
68+
{{ (ansible_os_family == 'RedHat' and ansible_distribution_major_version|int >= 8) or
69+
ansible_python_interpreter | basename is match('python3.*') }}

vars/Debian.yml

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

88
# Package that contains the libvirt daemon
99
libvirt_host_libvirt_packages_libvirt_daemon: >-

vars/RedHat.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
libvirt_host_libvirt_packages_default:
44
- libvirt
55
- libvirt-daemon-kvm
6-
- "{{ 'python3-libvirt' if ansible_distribution_major_version|int >=8 else 'libvirt-python' }}"
7-
- "{{ 'python3-lxml' if ansible_distribution_major_version|int >=8 else 'python-lxml' }}"
6+
- "{{ 'python3-libvirt' if libvirt_host_python3 | bool else 'libvirt-python' }}"
7+
- "{{ 'python3-lxml' if libvirt_host_python3 | bool else 'python-lxml' }}"
88
- qemu-kvm
99

1010
# Packages that are only necessary if you require EFI support

0 commit comments

Comments
 (0)