Fix setup for flatcar

This commit is contained in:
2026-06-15 23:51:50 +02:00
parent 3284e0ead7
commit 885f686ce7
@@ -22,18 +22,18 @@
- name: Handle compressed or raw images - name: Handle compressed or raw images
shell: | shell: |
DOWNLOAD_FILE="{{ vm_images_dir }}/{{ vm_name }}.download" DOWNLOAD_FILE="{{ vm_images_dir }}/{{ vm_name }}.download"
FINAL_FILE="{{ vm_images_dir }}/{{ vm_name }}.qcow2" FINAL_FILE="{{ vm_images_dir }}/{{ vm_name }}"
# 1. Handle XZ compression # 1. Handle XZ compression
if [[ "{{ os_images[os_type] }}" == *.xz ]]; then if [[ "{{ os_images[os_type] }}" == *.xz ]]; then
echo "Decompressing XZ image..." echo "Decompressing XZ image..."
unxz -c "$DOWNLOAD_FILE" > "$FINAL_FILE" unxz -c "$DOWNLOAD_FILE" > "$FINAL_FILE".qcow2
elif [[ "{{ os_images[os_type] }}" == *.img ]]; then elif [[ "{{ os_images[os_type] }}" == *.img ]]; then
echo "Converting RAW image to QCOW2..." echo "Moving IMG image to final destination..."
qemu-img convert -f raw -O qcow2 "$DOWNLOAD_FILE" "$FINAL_FILE" mv "$DOWNLOAD_FILE" "$FINAL_FILE".img
else else
echo "Moving QCOW2 image to final destination..." echo "Moving QCOW2 image to final destination..."
mv "$DOWNLOAD_FILE" "$FINAL_FILE" mv "$DOWNLOAD_FILE" "$FINAL_FILE".qcow2
fi fi
rm -f "$DOWNLOAD_FILE" rm -f "$DOWNLOAD_FILE"
become: yes become: yes
@@ -42,7 +42,7 @@
- name: Provision VM using virt-install - name: Provision VM using virt-install
shell: | shell: |
{% if os_type == 'coreos' or os_type == 'flatcar' %} {% if os_type == 'coreos' %}
virt-install \ virt-install \
--connect qemu:///system \ --connect qemu:///system \
--name {{ vm_name }} \ --name {{ vm_name }} \
@@ -55,6 +55,20 @@
--noautoconsole \ --noautoconsole \
--boot uefi \ --boot uefi \
--sysinfo type=fwcfg,entry0.name=opt/com.coreos/config,entry0.file={{ vm_images_dir }}/{{ vm_name }}.ign --sysinfo type=fwcfg,entry0.name=opt/com.coreos/config,entry0.file={{ vm_images_dir }}/{{ vm_name }}.ign
{% elif os_type == 'flatcar' %}
virt-install \
--connect qemu:///system \
--name {{ vm_name }} \
--vcpus {{ cpu | default(default_cpu) }} \
--memory {{ ram | default(default_ram) }} \
--disk path={{ vm_images_dir }}/{{ vm_name }}.img,format=qcow2,bus=virtio \
--import \
--os-variant {{ os_variant }} \
--network network=default \
--graphics none \
--noautoconsole \
--sysinfo system.serial=flatcar.first_boot=1 \
--qemu-commandline="-fw_cfg name=opt/org.flatcar-linux/config,file=/{{ vm_images_dir }}/{{ vm_name }}.ign"
{% elif os_type == 'microos' %} {% elif os_type == 'microos' %}
virt-install \ virt-install \
--name {{ vm_name }} \ --name {{ vm_name }} \