- 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.proxmox.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.proxmox.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