refactor ♻️: Simplify copy file from LXC container to host using pct exec
Replaced multiple commands with a single pct exec command for copying files between the LXC container and the host, improving code readability and maintainability.
This commit is contained in:
@@ -250,13 +250,18 @@
|
|||||||
tasks:
|
tasks:
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: Mount the LXC container filesystem
|
- name: Copy file from LXC container to host using pct exec
|
||||||
command: "pct mount {{ lxc_id }}"
|
command: pct exec "{{ lxc_id }}" -- cp {{ workdir }}/{{ template_name }}.qcow2 /var/lib/vz/template/qemu/
|
||||||
|
|
||||||
- name: Copy file from LXC container to the host
|
- name: Copy file from LXC container to host using rsync
|
||||||
copy:
|
command: pct exec "{{ lxc_id }}" -- rsync -av {{ workdir }}/{{ template_name }}.qcow2 /var/lib/vz/template/qemu/
|
||||||
src: "/var/lib/lxc/{{ lxc_id }}/rootfs/{{ workdir }}/{{ template_name }}.qcow2"
|
# - name: Mount the LXC container filesystem
|
||||||
dest: "/var/lib/vz/template/qemu/"
|
# 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
|
- name: Unmount the LXC container filesystem
|
||||||
command: "pct unmount {{ lxc_id }}"
|
command: "pct unmount {{ lxc_id }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user