try to move from lvm to zfs if needed
This commit is contained in:
@@ -40,7 +40,6 @@
|
|||||||
body:
|
body:
|
||||||
target: "{{ target_node }}"
|
target: "{{ target_node }}"
|
||||||
restart: "0"
|
restart: "0"
|
||||||
target-storage: "{{ target_storage }}"
|
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
status_code: [200]
|
status_code: [200]
|
||||||
register: migrate_task
|
register: migrate_task
|
||||||
@@ -59,6 +58,45 @@
|
|||||||
delay: 10
|
delay: 10
|
||||||
when: lxc_template_node != target_node
|
when: lxc_template_node != target_node
|
||||||
|
|
||||||
|
- name: Wait for LXC to unlock after migration
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
timeout: 30
|
||||||
|
when: lxc_template_node != target_node
|
||||||
|
|
||||||
|
- name: Move LXC rootfs to target storage (if different from local-lvm)
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ target_node }}/lxc/{{ cloned_lxc.vmid }}/move_volume"
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||||
|
body_format: form-urlencoded
|
||||||
|
body:
|
||||||
|
volume: "rootfs"
|
||||||
|
storage: "{{ target_storage }}"
|
||||||
|
delete: "1"
|
||||||
|
validate_certs: false
|
||||||
|
status_code: [200]
|
||||||
|
register: move_volume_task
|
||||||
|
when: target_storage != 'local-lvm'
|
||||||
|
|
||||||
|
- name: Wait for volume move to complete
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ target_node }}/lxc/{{ cloned_lxc.vmid }}/status/current"
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||||
|
validate_certs: false
|
||||||
|
register: lxc_status
|
||||||
|
until: lxc_status.json.data.lock is not defined
|
||||||
|
retries: 60
|
||||||
|
delay: 10
|
||||||
|
when: target_storage != 'local-lvm'
|
||||||
|
|
||||||
|
- name: Wait for LXC to unlock
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
timeout: 30
|
||||||
|
when: target_storage != 'local-lvm'
|
||||||
|
|
||||||
- name: Configure LXC resources
|
- name: Configure LXC resources
|
||||||
community.proxmox.proxmox:
|
community.proxmox.proxmox:
|
||||||
api_host: "{{ proxmox_api_host }}"
|
api_host: "{{ proxmox_api_host }}"
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
target: "{{ target_node }}"
|
target: "{{ target_node }}"
|
||||||
online: "0"
|
online: "0"
|
||||||
with-local-disks: "1"
|
with-local-disks: "1"
|
||||||
targetstorage: "{{ target_storage }}"
|
|
||||||
validate_certs: false
|
validate_certs: false
|
||||||
status_code: [200]
|
status_code: [200]
|
||||||
register: migrate_task
|
register: migrate_task
|
||||||
@@ -61,6 +60,40 @@
|
|||||||
delay: 10
|
delay: 10
|
||||||
when: vm_template_node != target_node
|
when: vm_template_node != target_node
|
||||||
|
|
||||||
|
- name: Wait for VM to unlock after migration
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
timeout: 30
|
||||||
|
when: vm_template_node != target_node
|
||||||
|
|
||||||
|
- name: Move VM disk to target storage (if different from local-lvm)
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ target_node }}/qemu/{{ cloned_vm.vmid }}/move_disk"
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||||
|
body_format: form-urlencoded
|
||||||
|
body:
|
||||||
|
disk: "scsi0"
|
||||||
|
storage: "{{ target_storage }}"
|
||||||
|
delete: "1"
|
||||||
|
validate_certs: false
|
||||||
|
status_code: [200]
|
||||||
|
register: move_disk_task
|
||||||
|
when: target_storage != 'local-lvm'
|
||||||
|
|
||||||
|
- name: Wait for disk move to complete
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ target_node }}/qemu/{{ cloned_vm.vmid }}/status/current"
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||||
|
validate_certs: false
|
||||||
|
register: vm_status
|
||||||
|
until: vm_status.json.data.lock is not defined
|
||||||
|
retries: 60
|
||||||
|
delay: 10
|
||||||
|
when: target_storage != 'local-lvm'
|
||||||
|
|
||||||
- name: Wait for VM to unlock
|
- name: Wait for VM to unlock
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
timeout: 30
|
timeout: 30
|
||||||
|
|||||||
Reference in New Issue
Block a user