dynamic storage selection

This commit is contained in:
2026-02-03 21:10:45 -05:00
parent bc4bd0c0d0
commit eb00b6bac5
2 changed files with 12 additions and 4 deletions

View File

@@ -1,13 +1,17 @@
---
- name: Get available storage on target node
- name: Get available storage on target node (filtered for images content)
ansible.builtin.uri:
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ target_node }}/storage"
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ target_node }}/storage?content=images&enabled=1"
method: GET
headers:
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
validate_certs: false
register: storage_info
- name: Debug available storage
ansible.builtin.debug:
msg: "Available storage on {{ target_node }}: {{ storage_info.json.data | map(attribute='storage') | list }}"
- name: Set storage backend (prefer local-zfs if available)
ansible.builtin.set_fact:
target_storage: "{{ 'local-zfs' if storage_info.json.data | selectattr('storage', 'equalto', 'local-zfs') | list | length > 0 else 'local-lvm' }}"