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:
|
||||
|
||||
- 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 }}"
|
||||
|
||||
Reference in New Issue
Block a user