38 lines
1.3 KiB
YAML
38 lines
1.3 KiB
YAML
- name: Build and Upload NixOS Image, Restore and Convert to Template
|
|
hosts: proxmox
|
|
gather_facts: false
|
|
|
|
vars:
|
|
image_dir: "{{ playbook_dir }}/../result"
|
|
dest_dir: "/var/lib/vz/dump/"
|
|
|
|
tasks:
|
|
- name: Get built image file (.vma.zst) from result/
|
|
ansible.builtin.find:
|
|
paths: "{{ result_path }}"
|
|
patterns: "*.vma.zst"
|
|
file_type: file # Ensure it's a file
|
|
register: built_image_files
|
|
delegate_to: localhost
|
|
|
|
- name: Fail if no image was built
|
|
ansible.builtin.fail:
|
|
msg: "No .vma.zst image file found in {{ result_path }}/"
|
|
when: built_image_files.files | length == 0
|
|
delegate_to: localhost
|
|
|
|
- name: Set fact for built image path and filename
|
|
ansible.builtin.set_fact:
|
|
local_image_path: "{{ built_image_files.files[0].path | realpath }}"
|
|
image_filename: "{{ built_image_files.files[0].path | basename }}"
|
|
delegate_to: localhost
|
|
|
|
- name: Display paths (for debugging)
|
|
ansible.builtin.debug:
|
|
msg: "Local image path: {{ local_image_path }}, Filename: {{ image_filename }}"
|
|
|
|
- name: Copy image to Proxmox server
|
|
ansible.builtin.copy:
|
|
src: "{{ local_image_path }}"
|
|
dest: "{{ dest_dir }}"
|
|
mode: "0644" # Ensure correct permissions on the destination
|