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"
|
- name: "[PREFLIGHT] Ensure Proxmox storage supports snippets"
|
||||||
block:
|
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:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/pve/storage.cfg
|
path: /etc/pve/storage.cfg
|
||||||
|
insertafter: "^dir: {{ proxmox_snippets_storage }}$"
|
||||||
regexp: "^(\\s*content\\s+)(.*)$"
|
regexp: "^(\\s*content\\s+)(.*)$"
|
||||||
line: '\1{{ (ansible_facts.storage_content.split(",") | union(["snippets"])) | join(",") }}'
|
line: '\1{{ (storage_content.split(",") | union(["snippets"])) | join(",") }}'
|
||||||
backrefs: yes
|
backrefs: yes
|
||||||
vars:
|
vars:
|
||||||
ansible_facts:
|
storage_content: >-
|
||||||
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('') }}"
|
{{ lookup('ansible.builtin.lines', '/etc/pve/storage.cfg')
|
||||||
|
| select('match', '^\\s*dir: {{ proxmox_snippets_storage }}')
|
||||||
- name: "[PREFLIGHT] Ensure snippets storage exists"
|
| list
|
||||||
|
| map('regex_search', '^\\s*content\\s+(.*)$')
|
||||||
|
| select('string')
|
||||||
|
| first
|
||||||
|
| default('') }}
|
||||||
|
|
||||||
|
- name: "[PREFLIGHT] Ensure snippets storage directory exists"
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ proxmox_snippets_storage_path }}/snippets"
|
path: "{{ proxmox_snippets_storage_path }}/snippets"
|
||||||
state: directory
|
state: directory
|
||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
- name: "[PREFLIGHT] Check snippets storage exists"
|
- name: "[PREFLIGHT] Verify snippets storage directory exists"
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ proxmox_snippets_storage_path }}/snippets"
|
path: "{{ proxmox_snippets_storage_path }}/snippets"
|
||||||
register: snippets_dir
|
register: snippets_dir
|
||||||
failed_when: not snippets_dir.stat.exists
|
failed_when: not snippets_dir.stat.exists
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: "[PREFLIGHT] Summary - All checks passed"
|
- name: "[PREFLIGHT] Summary - All checks passed"
|
||||||
|
|||||||
Reference in New Issue
Block a user