44 lines
1.7 KiB
YAML
44 lines
1.7 KiB
YAML
---
|
|
# =============================================================================
|
|
# proxmox_upgrade — restore.yml
|
|
# Optionally migrate guests back to original node after upgrade
|
|
# Only runs if migration_restore: true
|
|
# =============================================================================
|
|
|
|
- name: "Restore | Skip — migration_restore=false"
|
|
ansible.builtin.debug:
|
|
msg: "migration_restore=false — guests remain on {{ migration_target }}"
|
|
when: not migration_restore | bool
|
|
|
|
- name: "Restore | Migrate guests back to {{ current_node }}"
|
|
when: migration_restore | bool
|
|
block:
|
|
- name: "Restore | KVM | Migrate back to {{ current_node }}"
|
|
community.proxmox.proxmox_kvm:
|
|
api_host: "{{ api_host }}"
|
|
api_user: "{{ api_user }}"
|
|
api_token_id: "{{ api_token_id }}"
|
|
api_token_secret: "{{ api_token_secret }}"
|
|
api_port: "{{ api_port }}"
|
|
node: "{{ migration_target }}"
|
|
vmid: "{{ item.vmid }}"
|
|
migrate: true
|
|
target: "{{ current_node }}"
|
|
|
|
timeout: "{{ vm_shutdown_timeout }}"
|
|
loop: "{{ kvm_guests | default([]) }}"
|
|
delegate_to: localhost
|
|
|
|
- name: "Restore | LXC | Migrate back to {{ current_node }}"
|
|
ansible.builtin.command: >
|
|
pct migrate {{ item.vmid }} {{ current_node }}
|
|
{{ '--restart' if item.status == 'running' else '' }}
|
|
--timeout {{ lxc_migrate_timeout }}
|
|
loop: "{{ lxc_guests | default([]) }}"
|
|
when: live_migrate_fallback != 'skip'
|
|
changed_when: true
|
|
delegate_to: "{{ migration_target }}"
|
|
|
|
- name: "Restore | Complete"
|
|
ansible.builtin.debug:
|
|
msg: "All guests restored to {{ current_node }}" |