From 567b27264b23ef521b5027d91153b06d7b19cef9 Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 6 Dec 2025 09:08:18 +0100 Subject: [PATCH] fix: ensure Proxmox storage supports snippets and verify directory existence --- tasks/preflight-checks.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tasks/preflight-checks.yml b/tasks/preflight-checks.yml index b6fb804..b86b3a3 100644 --- a/tasks/preflight-checks.yml +++ b/tasks/preflight-checks.yml @@ -159,29 +159,35 @@ - name: "[PREFLIGHT] Ensure Proxmox storage supports snippets" block: - - name: "[PREFLIGHT] Ensure 'snippets' is in the content list for dir storage" + - name: "[PREFLIGHT] Ensure 'snippets' is in the content list for {{ proxmox_snippets_storage }}" ansible.builtin.lineinfile: path: /etc/pve/storage.cfg + insertafter: "^dir: {{ proxmox_snippets_storage }}$" regexp: "^(\\s*content\\s+)(.*)$" - line: '\1{{ (ansible_facts.storage_content.split(",") | union(["snippets"])) | join(",") }}' + line: '\1{{ (storage_content.split(",") | union(["snippets"])) | join(",") }}' backrefs: yes vars: - ansible_facts: - storage_content: "{{ lookup('ansible.builtin.lines', '/etc/pve/storage.cfg') | select('match', '^\\s*dir: {{ proxmox_snippets_storage }}') | list | map('regex_search', '^\\s*content\\s+(.*)$') | select('string') | first | default('') }}" - - - name: "[PREFLIGHT] Ensure snippets storage exists" + storage_content: >- + {{ lookup('ansible.builtin.lines', '/etc/pve/storage.cfg') + | select('match', '^\\s*dir: {{ proxmox_snippets_storage }}') + | list + | map('regex_search', '^\\s*content\\s+(.*)$') + | select('string') + | first + | default('') }} + + - name: "[PREFLIGHT] Ensure snippets storage directory exists" ansible.builtin.file: path: "{{ proxmox_snippets_storage_path }}/snippets" state: directory mode: "0755" - - name: "[PREFLIGHT] Check snippets storage exists" + - name: "[PREFLIGHT] Verify snippets storage directory exists" ansible.builtin.stat: path: "{{ proxmox_snippets_storage_path }}/snippets" register: snippets_dir failed_when: not snippets_dir.stat.exists changed_when: false - become: true - name: "[PREFLIGHT] Summary - All checks passed"