queries target node instead of template node
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
---
|
||||
- name: Get available storage on template node
|
||||
- name: Get available storage on target node
|
||||
ansible.builtin.uri:
|
||||
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ lxc_template_node }}/storage"
|
||||
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ target_node }}/storage"
|
||||
method: GET
|
||||
headers:
|
||||
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||
validate_certs: false
|
||||
register: storage_info
|
||||
|
||||
- name: Set storage backend (prefer local-zfs if available)
|
||||
- name: Set target storage backend (prefer local-zfs if available)
|
||||
ansible.builtin.set_fact:
|
||||
clone_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' }}"
|
||||
|
||||
- name: Display selected storage
|
||||
ansible.builtin.debug:
|
||||
msg: "Using storage backend: {{ clone_storage }}"
|
||||
msg: "Target node {{ target_node }} will use storage: {{ target_storage }}"
|
||||
|
||||
- name: Clone LXC from template (on template's node)
|
||||
community.proxmox.proxmox:
|
||||
@@ -26,7 +26,7 @@
|
||||
clone: "{{ lxc_template_id }}"
|
||||
hostname: "{{ vm_hostname }}"
|
||||
full: true
|
||||
storage: "{{ clone_storage }}"
|
||||
storage: "local-lvm"
|
||||
timeout: 600
|
||||
register: cloned_lxc
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
body:
|
||||
target: "{{ target_node }}"
|
||||
restart: "0"
|
||||
target-storage: "{{ target_storage }}"
|
||||
validate_certs: false
|
||||
status_code: [200]
|
||||
register: migrate_task
|
||||
|
||||
Reference in New Issue
Block a user