refactor ♻️: Improve template copy process for better performance

Updated the Ansible task to use rsync for copying templates between LXC containers and Proxmox hosts, reducing the need for qemu-img commands. This change also includes a warning flag to prevent potential issues with lxc-attach command.
This commit is contained in:
2025-11-08 21:45:54 +01:00
parent cb32af2ad4
commit 0c60000812

View File

@@ -225,14 +225,21 @@
# 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
ansible.posix.synchronize:
src: "{{ workdir }}/{{ template_name }}.qcow2"
dest: "/var/lib/vz/template/qemu/"
mode: push
# delegate_to: node0
# rsync_opts:
# - "--rsync-path='sudo rsync'"
# - name: Copy finished template back to Proxmox host
# ansible.posix.synchronize:
# src: "{{ workdir }}/{{ template_name }}.qcow2"
# dest: "/var/lib/vz/template/qemu/"
# mode: push
# # delegate_to: node0
# # rsync_opts:
# # - "--rsync-path='sudo rsync'"
- name: Copy file from LXC container to Proxmox host using rsync
ansible.builtin.command: >
rsync -a --rsh='lxc-attach -n {{ lxc_id }} --' {{ workdir }}/{{ template_name }}.qcow2 /var/lib/vz/template/qemu/
delegate_to: node0
args:
warn: false
- name: Import Debian Cloud image as Proxmox VM template
hosts: node0