From 0c60000812a5c41c8dfff6108b0d610d91535acc Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 8 Nov 2025 21:45:54 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Improve=20temp?= =?UTF-8?q?late=20copy=20process=20for=20better=20performance?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tasks/create_proxmox_debian_template.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tasks/create_proxmox_debian_template.yml b/tasks/create_proxmox_debian_template.yml index cf1de59..018559a 100644 --- a/tasks/create_proxmox_debian_template.yml +++ b/tasks/create_proxmox_debian_template.yml @@ -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