style 💎: Improve template creation process by adding QCOW2 image info and details
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.
This commit is contained in:
@@ -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: |
|
||||
|
||||
Reference in New Issue
Block a user