From ce7291bf3c42dcb9f5e9f92c52014317b70f41f9 Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 8 Nov 2025 23:18:02 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Simplify=20cop?= =?UTF-8?q?y=20file=20from=20LXC=20container=20to=20host=20using=20pct=20e?= =?UTF-8?q?xec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced multiple commands with a single pct exec command for copying files between the LXC container and the host, improving code readability and maintainability. --- tasks/create_proxmox_debian_template.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tasks/create_proxmox_debian_template.yml b/tasks/create_proxmox_debian_template.yml index 67aad8f..833a204 100644 --- a/tasks/create_proxmox_debian_template.yml +++ b/tasks/create_proxmox_debian_template.yml @@ -250,13 +250,18 @@ tasks: - block: - - name: Mount the LXC container filesystem - command: "pct mount {{ lxc_id }}" + - name: Copy file from LXC container to host using pct exec + command: pct exec "{{ lxc_id }}" -- cp {{ workdir }}/{{ template_name }}.qcow2 /var/lib/vz/template/qemu/ - - name: Copy file from LXC container to the host - copy: - src: "/var/lib/lxc/{{ lxc_id }}/rootfs/{{ workdir }}/{{ template_name }}.qcow2" - dest: "/var/lib/vz/template/qemu/" + - name: Copy file from LXC container to host using rsync + command: pct exec "{{ lxc_id }}" -- rsync -av {{ workdir }}/{{ template_name }}.qcow2 /var/lib/vz/template/qemu/ + # - name: Mount the LXC container filesystem + # command: "pct mount {{ lxc_id }}" + + # - name: Copy file from LXC container to the host + # copy: + # src: "/var/lib/lxc/{{ lxc_id }}/rootfs/{{ workdir }}/{{ template_name }}.qcow2" + # dest: "/var/lib/vz/template/qemu/" - name: Unmount the LXC container filesystem command: "pct unmount {{ lxc_id }}"