feat(proxmox): add k3s agents and refine VM provisioning
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
39
roles/proxmox/tasks/57_stop_and_verify_vm.yml
Normal file
39
roles/proxmox/tasks/57_stop_and_verify_vm.yml
Normal file
@@ -0,0 +1,39 @@
|
||||
- name: "Wait until success"
|
||||
block:
|
||||
- name: Set the retry count
|
||||
set_fact:
|
||||
retry_count: "{{ 0 if retry_count is undefined else retry_count | int + 1 }}"
|
||||
|
||||
- name: Stop VM
|
||||
community.general.proxmox_kvm:
|
||||
api_user: "{{ proxmox_api_user }}@pam"
|
||||
api_token_id: "{{ proxmox_api_token_id }}"
|
||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||
api_host: "192.168.20.12"
|
||||
node: "{{ vm.node }}"
|
||||
vmid: "{{ vm.vmid }}"
|
||||
state: stopped
|
||||
force: true
|
||||
|
||||
- name: Wait until VM is fully stopped
|
||||
community.general.proxmox_vm_info:
|
||||
api_user: "{{ proxmox_api_user }}@pam"
|
||||
api_token_id: "{{ proxmox_api_token_id }}"
|
||||
api_token_secret: "{{ proxmox_api_token_secret }}"
|
||||
api_host: "192.168.20.12"
|
||||
node: "{{ vm.node }}"
|
||||
vmid: "{{ vm.vmid }}"
|
||||
register: vm_status_check
|
||||
failed_when: vm_status_check.proxmox_vms[0].status != "stopped"
|
||||
rescue:
|
||||
- name: Check for retry count
|
||||
fail:
|
||||
msg: Ended after 24 retries
|
||||
when: retry_count|int == 24
|
||||
|
||||
- name: Wait 5s
|
||||
ansible.builtin.pause:
|
||||
seconds: 5
|
||||
|
||||
- name: "Failed to stop VM - Retrying..."
|
||||
include_tasks: ./57_stop_and_verify_vm.yml
|
||||
Reference in New Issue
Block a user