updated back to api
This commit is contained in:
@@ -13,17 +13,32 @@
|
|||||||
timeout: 600
|
timeout: 600
|
||||||
register: cloned_lxc
|
register: cloned_lxc
|
||||||
|
|
||||||
- name: Migrate LXC to target node
|
- name: Migrate LXC to target node via API
|
||||||
community.proxmox.proxmox:
|
ansible.builtin.uri:
|
||||||
api_host: "{{ proxmox_api_host }}"
|
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ lxc_template_node }}/lxc/{{ cloned_lxc.vmid }}/migrate"
|
||||||
api_user: "{{ proxmox_api_user }}"
|
method: POST
|
||||||
api_token_id: "{{ proxmox_api_token_id }}"
|
headers:
|
||||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||||
node: "{{ lxc_template_node }}"
|
body_format: form-urlencoded
|
||||||
vmid: "{{ cloned_lxc.vmid }}"
|
body:
|
||||||
target: "{{ target_node }}"
|
target: "{{ target_node }}"
|
||||||
state: present
|
restart: "0"
|
||||||
timeout: 600
|
validate_certs: false
|
||||||
|
status_code: [200]
|
||||||
|
register: migrate_task
|
||||||
|
when: lxc_template_node != target_node
|
||||||
|
|
||||||
|
- name: Wait for migration task 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_check
|
||||||
|
until: lxc_check.status == 200
|
||||||
|
retries: 60
|
||||||
|
delay: 10
|
||||||
when: lxc_template_node != target_node
|
when: lxc_template_node != target_node
|
||||||
|
|
||||||
- name: Configure LXC resources
|
- name: Configure LXC resources
|
||||||
|
|||||||
@@ -14,17 +14,33 @@
|
|||||||
timeout: 600
|
timeout: 600
|
||||||
register: cloned_vm
|
register: cloned_vm
|
||||||
|
|
||||||
- name: Migrate VM to target node
|
- name: Migrate VM to target node via API
|
||||||
community.proxmox.proxmox_kvm:
|
ansible.builtin.uri:
|
||||||
api_host: "{{ proxmox_api_host }}"
|
url: "https://{{ proxmox_api_host }}:8006/api2/json/nodes/{{ vm_template_node }}/qemu/{{ cloned_vm.vmid }}/migrate"
|
||||||
api_user: "{{ proxmox_api_user }}"
|
method: POST
|
||||||
api_token_id: "{{ proxmox_api_token_id }}"
|
headers:
|
||||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token_id }}={{ proxmox_api_token_secret }}"
|
||||||
node: "{{ vm_template_node }}"
|
body_format: form-urlencoded
|
||||||
vmid: "{{ cloned_vm.vmid }}"
|
body:
|
||||||
migrate: true
|
|
||||||
target: "{{ target_node }}"
|
target: "{{ target_node }}"
|
||||||
timeout: 600
|
online: "0"
|
||||||
|
with-local-disks: "1"
|
||||||
|
validate_certs: false
|
||||||
|
status_code: [200]
|
||||||
|
register: migrate_task
|
||||||
|
when: vm_template_node != target_node
|
||||||
|
|
||||||
|
- name: Wait for migration task 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_check
|
||||||
|
until: vm_check.status == 200
|
||||||
|
retries: 60
|
||||||
|
delay: 10
|
||||||
when: vm_template_node != target_node
|
when: vm_template_node != target_node
|
||||||
|
|
||||||
- name: Configure VM resources
|
- name: Configure VM resources
|
||||||
|
|||||||
Reference in New Issue
Block a user