44 lines
1.5 KiB
YAML
44 lines
1.5 KiB
YAML
---
|
|
- name: Fetch VM status
|
|
uri:
|
|
url : "{{ __pve_endpoint }}/nodes/{{ item.vm_host | default(__pve_node) }}/qemu/\
|
|
{{ item.vmid }}/status/current"
|
|
method : GET
|
|
headers :
|
|
Content-type : "application/x-www-form-urlencoded"
|
|
Authorization : "{{ __pve_token }}"
|
|
vmid : "{{ item.vmid }}"
|
|
return_content : no
|
|
validate_certs : no
|
|
register : r_fetch_status
|
|
loop : "{{ lab_nodes }}"
|
|
loop_control :
|
|
label : "{{ item.name }}"
|
|
until : r_fetch_status.status == 200 and r_fetch_status.json.data.status is defined
|
|
retries : "{{ __api_retries }}"
|
|
delay : "{{ __api_polling }}"
|
|
|
|
|
|
- name: Start VMs
|
|
uri:
|
|
url : "{{ __pve_endpoint }}/nodes/{{ item.item.vm_host | default(__pve_node) }}/qemu/\
|
|
{{ item.item.vmid }}/status/start"
|
|
method : POST
|
|
headers :
|
|
Content-type : "application/x-www-form-urlencoded"
|
|
Authorization : "{{ __pve_token }}"
|
|
vmid : "{{ item.item.vmid }}"
|
|
return_content : no
|
|
validate_certs : no
|
|
register : r_start_vm
|
|
loop : "{{ r_fetch_status.results }}"
|
|
loop_control :
|
|
label : "{{ item.json.data.name }}"
|
|
pause : "{{ __vm_start_delay }}" # pause added to prevent i/o overload
|
|
# on larger labs
|
|
when :
|
|
- item.json.data.status == 'stopped'|lower
|
|
|
|
|
|
...
|