fix: update preflight checks to ensure 'snippets' is included in Proxmox storage content list

This commit is contained in:
2025-12-06 08:40:48 +01:00
parent b8718a23a5
commit 8c031a915d

View File

@@ -168,16 +168,20 @@
set_fact:
storage_cfg: "{{ storage_cfg_raw.content | b64decode }}"
- name: "[PREFLIGHT] Add 'snippets' to storage content list if missing"
- name: "[PREFLIGHT] Get current content list of the target storage"
ansible.builtin.shell: >
awk '/^dir: {{ proxmox_snippets_storage }}/,/^$/' /etc/pve/storage.cfg |
awk '/content/ {print $3}'
register: current_content
changed_when: false
- name: "[PREFLIGHT] Ensure 'snippets' is in the content list"
ansible.builtin.replace:
path: /etc/pve/storage.cfg
regexp: "(?m)(^storage {{ proxmox_snippets_storage }}.*?content\\s*=\\s*)([^\n]+)"
replace: >-
\1{{ ( '\2'.split(',') | union(['snippets']) ) | join(',') }}
when:
- storage_cfg is search("storage " + proxmox_snippets_storage)
- storage_cfg is search("storage " + proxmox_snippets_storage + ".*content=")
regexp: "(?m)(^dir: {{ proxmox_snippets_storage }}[\\s\\S]*?content\\s*=\\s*)([^\\n]+)"
replace: "\\1{{ (current_content.stdout.split(',') | union(['snippets'])) | join(',') }}"
when: current_content.stdout != ""
- name: "[PREFLIGHT] Ensure snippets storage exists"
ansible.builtin.file:
path: "{{ proxmox_snippets_storage_path }}/snippets"