diff --git a/handlers/main.yml b/handlers/main.yml index 5c9159b..0cf0cb8 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -73,18 +73,21 @@ changed_when: proxmox_maintenance_disabled.rc == 0 listen: Disable maintenance mode -# TO DEBUG: -#- name: Wait until node quits maintenance mode -# ansible.builtin.command: -# argv: -# - ha-manager -# - status -# become: true -# register: proxmox_ha_manager_status -# changed_when: >- -# proxmox_ha_manager_status.stdout_lines | select("search", "lrm " + inventory_hostname_short +" (active") | list | length > 0 -# retries: 20 -# delay: 30 -# until: >- -# proxmox_ha_manager_status.stdout_lines | select("search", "lrm " + inventory_hostname_short + " (active") | list | length > 0 -# listen: Disable maintenance mode +- name: Wait for the instances to return to the current host + community.proxmox.proxmox_vm_info: + api_host: "{{ proxmox_api_host }}" + api_token_id: "{{ proxmox_api_token_id }}" + api_token_secret: "{{ proxmox_api_token_secret }}" + api_user: "{{ proxmox_api_user }}" + node: "{{ inventory_hostname_short }}" + type: all + validate_certs: "{{ proxmox_api_validate_certs }}" + become: true + register: proxmox_current_instances + retries: 20 + delay: 30 + until: current == expected + vars: + current: "{{ proxmox_current_instances.proxmox_vms | map(attribute='name') | sort }}" + expected: "{{ proxmox_node_instances.proxmox_vms | map(attribute='name') | sort }}" + listen: Disable maintenance mode diff --git a/tasks/node_update.yml b/tasks/node_update.yml index f3aba5f..6d03a69 100644 --- a/tasks/node_update.yml +++ b/tasks/node_update.yml @@ -17,6 +17,18 @@ - name: Upgrade tasks when: apt_upgradable.stdout_lines | length > 1 block: + - name: List instance on the current node + community.proxmox.proxmox_vm_info: + api_host: "{{ proxmox_api_host }}" + api_token_id: "{{ proxmox_api_token_id }}" + api_token_secret: "{{ proxmox_api_token_secret }}" + api_user: "{{ proxmox_api_user }}" + node: "{{ inventory_hostname_short }}" + type: all + validate_certs: "{{ proxmox_api_validate_certs }}" + become: true + register: proxmox_node_instances + - name: Enable maintenance node ansible.builtin.command: argv: