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:
@@ -225,14 +225,21 @@
|
|||||||
# qemu-img convert -O qcow2 -c {{ workdir }}/{{ image_name }} {{ workdir }}/{{ template_name }}.qcow2
|
# qemu-img convert -O qcow2 -c {{ workdir }}/{{ image_name }} {{ workdir }}/{{ template_name }}.qcow2
|
||||||
# qemu-img resize {{ workdir }}/{{ template_name }}.qcow2 --shrink
|
# qemu-img resize {{ workdir }}/{{ template_name }}.qcow2 --shrink
|
||||||
|
|
||||||
- name: Copy finished template back to Proxmox host
|
# - name: Copy finished template back to Proxmox host
|
||||||
ansible.posix.synchronize:
|
# ansible.posix.synchronize:
|
||||||
src: "{{ workdir }}/{{ template_name }}.qcow2"
|
# src: "{{ workdir }}/{{ template_name }}.qcow2"
|
||||||
dest: "/var/lib/vz/template/qemu/"
|
# dest: "/var/lib/vz/template/qemu/"
|
||||||
mode: push
|
# mode: push
|
||||||
# delegate_to: node0
|
# # delegate_to: node0
|
||||||
# rsync_opts:
|
# # rsync_opts:
|
||||||
# - "--rsync-path='sudo rsync'"
|
# # - "--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
|
- name: Import Debian Cloud image as Proxmox VM template
|
||||||
hosts: node0
|
hosts: node0
|
||||||
|
|||||||
Reference in New Issue
Block a user