fix: ensure Proxmox storage supports snippets and verify directory existence
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user