diff --git a/README.md b/README.md index d2c8869..ffbc642 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,10 @@ init system when libvirtd is started - quotes will be added an explicit connection URI will not be set when calling virsh or any of the virt_ ansible modules. +`libvirt_host_python3`: Whether the python3 version of the libvirt python +bindings should be installed. If `false`, the python 2 bindings will be +installed. + Dependencies ------------ diff --git a/defaults/main.yml b/defaults/main.yml index eca224f..0f32b67 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -61,3 +61,9 @@ libvirt_host_uri: >- {%- if libvirt_host_socket_dir -%} qemu+unix:///system?socket={{ libvirt_host_socket_dir }}/libvirt-sock {%- endif %} + +# 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_os_family == 'RedHat' and ansible_distribution_major_version|int >= 8) or + ansible_python_interpreter | basename is match('python3.*') }} diff --git a/vars/Debian.yml b/vars/Debian.yml index 7353d0b..49e5cea 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -2,8 +2,8 @@ # List of package dependencies common to all Debian distributions libvirt_host_libvirt_packages_common: - qemu-kvm - - python-libvirt - - python-lxml + - "{{ '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: >- diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 5ce175d..b0c501d 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -3,8 +3,8 @@ libvirt_host_libvirt_packages_default: - libvirt - libvirt-daemon-kvm - - "{{ 'python3-libvirt' if ansible_distribution_major_version|int >=8 else 'libvirt-python' }}" - - "{{ 'python3-lxml' if ansible_distribution_major_version|int >=8 else 'python-lxml' }}" + - "{{ '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