Description: Fix libvirt setup under >= Bullseye
Author: Thomas Goirand <zigo@debian.org>
Forwarded: no
Last-Update: 2021-01-25

--- puppet-module-nova-17.5.0.orig/manifests/migration/libvirt.pp
+++ puppet-module-nova-17.5.0/manifests/migration/libvirt.pp
@@ -115,6 +115,12 @@ class nova::migration::libvirt(
 
   include nova::deps
 
+  if $facts['os']['lsb'] != undef{
+    $mycodename = $facts['os']['lsb']['distcodename']
+  }else{
+    $mycodename = $facts['os']['distro']['codename']
+  }
+
   if $transport {
     $transport_real = $transport
   } else {
@@ -206,9 +212,16 @@ class nova::migration::libvirt(
       }
     }
 
-    libvirtd_config {
-      'listen_tls': value => $listen_tls;
-      'listen_tcp': value => $listen_tcp;
+    if $mycodename == "stretch" or $mycodename == "buster" {
+      libvirtd_config {
+        'listen_tls': value => $listen_tls;
+      }
+    }
+
+    if $mycodename == "stretch" or $mycodename == "buster" {
+      libvirtd_config {
+        'listen_tcp': value => $listen_tcp;
+      }
     }
 
     if $transport_real == 'tls' {
@@ -226,8 +239,10 @@ class nova::migration::libvirt(
         }
       }
     } elsif $transport_real == 'tcp' {
-      libvirtd_config {
-        'auth_tcp': value => "\"${auth}\"";
+      if $mycodename == "stretch" or $mycodename == "buster" {
+        libvirtd_config {
+          'auth_tcp': value => "\"${auth}\"";
+        }
       }
     }
 
@@ -276,11 +291,13 @@ class nova::migration::libvirt(
 
       'Debian': {
         if $transport_real != 'ssh' {
-          file_line { "/etc/default/${::nova::compute::libvirt::libvirt_service_name} libvirtd opts":
-            path  => "/etc/default/${::nova::compute::libvirt::libvirt_service_name}",
-            line  => 'libvirtd_opts="-l"',
-            match => 'libvirtd_opts=',
-            tag   => 'libvirt-file_line',
+          if $mycodename == "stretch" or $mycodename == "buster" {
+            file_line { "/etc/default/${::nova::compute::libvirt::libvirt_service_name} libvirtd opts":
+              path  => "/etc/default/${::nova::compute::libvirt::libvirt_service_name}",
+              line  => 'libvirtd_opts="-l"',
+              match => 'libvirtd_opts=',
+              tag   => 'libvirt-file_line',
+            }
           }
         }
       }
