feat: Implement Debian VM template creation and cloning on Proxmox
- Added default configuration for VM creation in defaults/main.yml. - Created tasks for configuring the VM with UEFI, TPM, disks, GPU, and Cloud-Init in tasks/configure-vm.yml. - Implemented clone creation and configuration logic in tasks/create-clones.yml. - Added template conversion functionality in tasks/create-template.yml. - Developed base VM creation logic in tasks/create-vm.yml. - Included image download and caching tasks in tasks/download-image.yml. - Introduced utility tasks for common operations in tasks/helpers.yml. - Organized main orchestration logic in tasks/main.yml, with clear stages for each operation. - Added pre-flight checks to validate the environment before execution in tasks/preflight-checks.yml.
This commit is contained in:
41
tasks/download-image.yml
Normal file
41
tasks/download-image.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
---
|
||||
# download-image.yml - Download and cache Debian GenericCloud image
|
||||
|
||||
- name: "[IMAGE] Check for Debian GenericCloud image"
|
||||
stat:
|
||||
path: "{{ debian_image_path }}"
|
||||
register: debian_img
|
||||
changed_when: false
|
||||
|
||||
- name: "[IMAGE] Create template directory if missing"
|
||||
file:
|
||||
path: "/var/lib/vz/template/qemu"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
when: not debian_img.stat.exists
|
||||
|
||||
- name: "[IMAGE] Download Debian GenericCloud qcow2"
|
||||
get_url:
|
||||
url: "{{ debian_image_url }}"
|
||||
dest: "{{ debian_image_path }}"
|
||||
mode: "0644"
|
||||
timeout: 300
|
||||
register: image_download
|
||||
retries: 3
|
||||
delay: 5
|
||||
until: image_download is succeeded
|
||||
when: not debian_img.stat.exists
|
||||
|
||||
- name: "[IMAGE] Verify downloaded image integrity"
|
||||
stat:
|
||||
path: "{{ debian_image_path }}"
|
||||
register: debian_img_final
|
||||
changed_when: false
|
||||
failed_when: not debian_img_final.stat.exists or debian_img_final.stat.size == 0
|
||||
|
||||
- name: "[IMAGE] Display image info"
|
||||
debug:
|
||||
msg: |
|
||||
Image cached at: {{ debian_image_path }}
|
||||
Size: {{ debian_img_final.stat.size | int / 1024 / 1024 / 1024 | round(2) }} GB
|
||||
Last modified: {{ debian_img_final.stat.mtime | timestamp_to_datetime }}
|
||||
Reference in New Issue
Block a user