style 💎: Update image compression and shrinking steps
Updated the Ansible playbook to use virt-sparsify for compressing and shrinking images, replacing a previous qemu-img command. This change improves efficiency and reduces storage requirements.
This commit is contained in:
@@ -10,7 +10,8 @@
|
|||||||
vars:
|
vars:
|
||||||
lxc_name: "debian-builder"
|
lxc_name: "debian-builder"
|
||||||
lxc_id: 9900
|
lxc_id: 9900
|
||||||
lxc_storage: "local-lvm"
|
# lxc_storage: "local-lvm"
|
||||||
|
lxc_storage: "hdd8t"
|
||||||
lxc_template: "local:vztmpl/debian-13-standard_13.1-1_amd64.tar.zst"
|
lxc_template: "local:vztmpl/debian-13-standard_13.1-1_amd64.tar.zst"
|
||||||
lxc_ostype: "debian"
|
lxc_ostype: "debian"
|
||||||
lxc_cores: 2
|
lxc_cores: 2
|
||||||
@@ -140,10 +141,26 @@
|
|||||||
virt-customize -a {{ workdir }}/{{ image_name }} \
|
virt-customize -a {{ workdir }}/{{ image_name }} \
|
||||||
--run-command 'truncate -s 0 /etc/machine-id && rm -f /var/lib/dbus/machine-id'
|
--run-command 'truncate -s 0 /etc/machine-id && rm -f /var/lib/dbus/machine-id'
|
||||||
|
|
||||||
- name: Compress and shrink image
|
- name: Convert image to compressed qcow2
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
qemu-img convert -O qcow2 -c {{ workdir }}/{{ image_name }} {{ workdir }}/{{ template_name }}.qcow2
|
qemu-img convert -O qcow2 -c {{ workdir }}/{{ image_name }} {{ workdir }}/{{ template_name }}.qcow2
|
||||||
qemu-img resize {{ workdir }}/{{ template_name }}.qcow2 --shrink
|
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: Replace original compressed image with sparsified version
|
||||||
|
ansible.builtin.shell: |
|
||||||
|
mv {{ workdir }}/{{ template_name }}_sparse.qcow2 {{ workdir }}/{{ template_name }}.qcow2
|
||||||
|
|
||||||
|
# - name: Compress and shrink image
|
||||||
|
# ansible.builtin.shell: |
|
||||||
|
# qemu-img convert -O qcow2 -c {{ workdir }}/{{ image_name }} {{ workdir }}/{{ template_name }}.qcow2
|
||||||
|
# qemu-img resize {{ workdir }}/{{ template_name }}.qcow2 --shrink
|
||||||
|
|
||||||
- name: Copy finished template back to Proxmox host
|
- name: Copy finished template back to Proxmox host
|
||||||
ansible.builtin.synchronize:
|
ansible.builtin.synchronize:
|
||||||
|
|||||||
Reference in New Issue
Block a user