ansiiiible
This commit is contained in:
parent
85d0217436
commit
a8aa633c49
12 changed files with 314 additions and 0 deletions
38
ansible/playbooks/upload-image.yml
Normal file
38
ansible/playbooks/upload-image.yml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
- 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue