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"
|
mode: "0644"
|
||||||
force: true
|
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
|
- name: Customize image with base utilities and root password
|
||||||
ansible.builtin.command: >
|
ansible.builtin.command: >
|
||||||
virt-customize -a {{ workdir }}/{{ image_name }}
|
virt-customize -a {{ workdir }}/{{ image_name }}
|
||||||
@@ -143,17 +155,53 @@
|
|||||||
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: 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
|
- 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
|
||||||
args:
|
args:
|
||||||
creates: "{{ workdir }}/{{ template_name }}.qcow2"
|
creates: "{{ workdir }}/{{ template_name }}.qcow2"
|
||||||
|
|
||||||
- name: Shrink the compressed qcow2 using virt-sparsify
|
|
||||||
ansible.builtin.shell: |
|
- name: Get QCOW2 image info
|
||||||
virt-sparsify --compress {{ workdir }}/{{ template_name }}.qcow2 {{ workdir }}/{{ template_name }}_sparse.qcow2
|
ansible.builtin.shell: qemu-img info {{ workdir }}/linux-vm.qcow2
|
||||||
args:
|
register: image_info
|
||||||
creates: "{{ workdir }}/{{ template_name }}_sparse.qcow2"
|
|
||||||
|
- 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
|
- name: Replace original compressed image with sparsified version
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
|
|||||||
Reference in New Issue
Block a user