dynamic storage selection
This commit is contained in:
@@ -1,13 +1,17 @@
|
|||||||
---
|
---
|
||||||
- name: Get available storage on target node
|
- name: Get available storage on target node (filtered for rootdir content)
|
||||||
ansible.builtin.uri:
|
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=rootdir&enabled=1"
|
||||||
method: GET
|
method: GET
|
||||||
headers:
|
headers:
|
||||||
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
register: storage_info
|
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)
|
- name: Set storage backend (prefer local-zfs if available)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
target_storage: "{{ 'local-zfs' if storage_info.json.data | selectattr('storage', 'equalto', 'local-zfs') | list | length > 0 else 'local-lvm' }}"
|
target_storage: "{{ 'local-zfs' if storage_info.json.data | selectattr('storage', 'equalto', 'local-zfs') | list | length > 0 else 'local-lvm' }}"
|
||||||
|
|||||||
@@ -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:
|
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
|
method: GET
|
||||||
headers:
|
headers:
|
||||||
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
register: storage_info
|
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)
|
- name: Set storage backend (prefer local-zfs if available)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
target_storage: "{{ 'local-zfs' if storage_info.json.data | selectattr('storage', 'equalto', 'local-zfs') | list | length > 0 else 'local-lvm' }}"
|
target_storage: "{{ 'local-zfs' if storage_info.json.data | selectattr('storage', 'equalto', 'local-zfs') | list | length > 0 else 'local-lvm' }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user