Parameterize qemu-kvm emulator path for portability across Linux distros. 85/12985/1
authorChris Wheeler <chwheele@redhat.com>
Mon, 17 Jun 2024 16:59:59 +0000 (09:59 -0700)
committerChris Wheeler <chwheele@redhat.com>
Mon, 17 Jun 2024 16:59:59 +0000 (09:59 -0700)
Issue-ID: INF-441
Change-Id: I7da6fd4fff3464605145acdf9c1114ef2242bcfe
Signed-off-by: Chris Wheeler <chwheele@redhat.com>
okd/roles/ocloud_infra_vm/tasks/main.yml
okd/roles/ocloud_infra_vm/templates/virt.xml.j2

index 320e4df..0594ecb 100644 (file)
   run_once: true
   become: true
 
+- name: Locate qemu-kvm emulator
+  stat:
+    path: "{{ item }}"
+  register: ocloud_infra_vm_emulator_stat
+  loop:
+    - /usr/bin/qemu-kvm
+    - /usr/libexec/qemu-kvm
+
+- set_fact:
+    ocloud_infra_vm_emulator_path: "{{ item.stat.path }}"
+  when: item.stat.exists
+  loop: "{{ ocloud_infra_vm_emulator_stat.results }}"
+
 - name: Create virtual machine - {{ inventory_hostname }}
   community.libvirt.virt:
     command: define
index 3f6565e..283faf7 100644 (file)
@@ -25,7 +25,7 @@
     <suspend-to-disk enabled='no'/>
   </pm>
   <devices>
-    <emulator>/usr/libexec/qemu-kvm</emulator>
+    <emulator>{{ ocloud_infra_vm_emulator_path }}</emulator>
     <disk type='file' device='disk'>
       <driver name='qemu' type='qcow2'/>
       <source file='{{ ocloud_infra_vm_disk_path }}'/>