From 710c76d72b42aa6b9d3b42bd857afcd9827b460b Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 8 Nov 2025 17:34:23 +0100 Subject: [PATCH] =?UTF-8?q?style=20=F0=9F=92=8E:=20Improve=20template=20cr?= =?UTF-8?q?eation=20process=20by=20adding=20QCOW2=20image=20info=20and=20d?= =?UTF-8?q?etails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added shell commands to display QCOW2 image information and details, making the template creation process more informative and user-friendly. This change improves the overall experience for users creating Proxmox Debian templates. --- tasks/create_proxmox_debian_template.yml | 58 ++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/tasks/create_proxmox_debian_template.yml b/tasks/create_proxmox_debian_template.yml index 87b7a10..499b196 100644 --- a/tasks/create_proxmox_debian_template.yml +++ b/tasks/create_proxmox_debian_template.yml @@ -127,6 +127,18 @@ mode: "0644" force: true + + - name: Get QCOW2 image info + ansible.builtin.shell: qemu-img info {{ workdir }}/linux-vm.qcow2 + register: image_info + + - name: Show QCOW2 image details + ansible.builtin.debug: + msg: | + === QCOW2 Image Info === + {{ image_info.stdout }} + + - name: Customize image with base utilities and root password ansible.builtin.command: > virt-customize -a {{ workdir }}/{{ image_name }} @@ -143,17 +155,53 @@ virt-customize -a {{ workdir }}/{{ image_name }} \ --run-command 'truncate -s 0 /etc/machine-id && rm -f /var/lib/dbus/machine-id' + + - name: Get QCOW2 image info + ansible.builtin.shell: qemu-img info {{ workdir }}/linux-vm.qcow2 + register: image_info + + - name: Show QCOW2 image details + ansible.builtin.debug: + msg: | + === QCOW2 Image Info === + {{ image_info.stdout }} + + - name: Convert image to compressed qcow2 ansible.builtin.shell: | qemu-img convert -O qcow2 -c {{ workdir }}/{{ image_name }} {{ workdir }}/{{ template_name }}.qcow2 args: creates: "{{ workdir }}/{{ template_name }}.qcow2" - - name: Shrink the compressed qcow2 using virt-sparsify - ansible.builtin.shell: | - virt-sparsify --compress {{ workdir }}/{{ template_name }}.qcow2 {{ workdir }}/{{ template_name }}_sparse.qcow2 - args: - creates: "{{ workdir }}/{{ template_name }}_sparse.qcow2" + + - name: Get QCOW2 image info + ansible.builtin.shell: qemu-img info {{ workdir }}/linux-vm.qcow2 + register: image_info + + - name: Show QCOW2 image details + ansible.builtin.debug: + msg: | + === QCOW2 Image Info === + {{ image_info.stdout }} + + + # - name: Shrink the compressed qcow2 using virt-sparsify + # ansible.builtin.shell: | + # virt-sparsify --compress {{ workdir }}/{{ template_name }}.qcow2 {{ workdir }}/{{ template_name }}_sparse.qcow2 + # args: + # creates: "{{ workdir }}/{{ template_name }}_sparse.qcow2" + + + # - name: Get QCOW2 image info + # ansible.builtin.shell: qemu-img info {{ workdir }}/linux-vm.qcow2 + # register: image_info + + # - name: Show QCOW2 image details + # ansible.builtin.debug: + # msg: | + # === QCOW2 Image Info === + # {{ image_info.stdout }} + - name: Replace original compressed image with sparsified version ansible.builtin.shell: |