Update roles/proxmox_upgrade/tasks/drain.yml
This commit is contained in:
@@ -45,12 +45,16 @@
|
||||
when: migration_target is not defined or migration_target == ''
|
||||
delegate_to: localhost
|
||||
|
||||
- name: "Drain | Log raw guest data (for debugging)"
|
||||
ansible.builtin.debug:
|
||||
msg: "Guests on {{ current_node }}: {{ node_guests.proxmox_vms | map(attribute='vmid') | list }} — tags sample: {{ node_guests.proxmox_vms | map(attribute='tags') | list }}"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: "Drain | Build KVM migration list"
|
||||
ansible.builtin.set_fact:
|
||||
kvm_guests: >-
|
||||
{{ node_guests.proxmox_vms
|
||||
| selectattr('type', 'equalto', 'qemu')
|
||||
| rejectattr('tags', 'intersect', migrate_exclude_tags)
|
||||
| list }}
|
||||
delegate_to: localhost
|
||||
|
||||
@@ -59,7 +63,6 @@
|
||||
lxc_guests: >-
|
||||
{{ node_guests.proxmox_vms
|
||||
| selectattr('type', 'equalto', 'lxc')
|
||||
| rejectattr('tags', 'intersect', migrate_exclude_tags)
|
||||
| list }}
|
||||
delegate_to: localhost
|
||||
|
||||
@@ -67,8 +70,8 @@
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
Drain plan for {{ current_node }} → {{ migration_target }}:
|
||||
KVM: {{ kvm_guests | map(attribute='vmid') | list }}
|
||||
LXC: {{ lxc_guests | map(attribute='vmid') | list }}
|
||||
KVM ({{ kvm_guests | length }}): {{ kvm_guests | map(attribute='vmid') | list }}
|
||||
LXC ({{ lxc_guests | length }}): {{ lxc_guests | map(attribute='vmid') | list }}
|
||||
delegate_to: localhost
|
||||
|
||||
# ── KVM migrations ────────────────────────────────────────────────────────────
|
||||
@@ -86,13 +89,13 @@
|
||||
vmid: "{{ item.vmid }}"
|
||||
migrate: true
|
||||
target_node: "{{ migration_target }}"
|
||||
online: "{{ true if item.status == 'running' and not item.get('needs_fallback', false) else false }}"
|
||||
online: "{{ true if item.status == 'running' else false }}"
|
||||
timeout: "{{ vm_shutdown_timeout }}"
|
||||
loop: "{{ kvm_guests }}"
|
||||
delegate_to: localhost
|
||||
when: not migration_bulk | bool
|
||||
|
||||
- name: "Drain | KVM | Bulk migrate (fire and wait)"
|
||||
- name: "Drain | KVM | Bulk migrate (fire all simultaneously)"
|
||||
community.proxmox.proxmox_kvm:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ api_user }}"
|
||||
@@ -131,42 +134,38 @@
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
LXC {{ item.vmid }} ({{ item.name | default('unknown') }}) will be
|
||||
stopped, migrated to {{ migration_target }}, and restarted
|
||||
(LXC live migration is not supported by Proxmox).
|
||||
stopped, migrated to {{ migration_target }}, and restarted.
|
||||
(LXC live migration is not supported by Proxmox)
|
||||
loop: "{{ lxc_guests | selectattr('status', 'equalto', 'running') | list }}"
|
||||
delegate_to: localhost
|
||||
|
||||
- name: "Drain | LXC | Warn about skipped containers"
|
||||
- name: "Drain | LXC | Skip warning"
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
WARNING — LXC {{ item.vmid }} ({{ item.name | default('unknown') }})
|
||||
live_migrate_fallback=skip — this container WILL GO DOWN during node reboot.
|
||||
live_migrate_fallback=skip — THIS CONTAINER WILL GO DOWN during node reboot.
|
||||
loop: "{{ lxc_guests | selectattr('status', 'equalto', 'running') | list }}"
|
||||
when: live_migrate_fallback == 'skip'
|
||||
delegate_to: localhost
|
||||
|
||||
- name: "Drain | LXC | Migrate via pct migrate --restart"
|
||||
- name: "Drain | LXC | Migrate via pct migrate"
|
||||
ansible.builtin.command: >
|
||||
pct migrate {{ item.vmid }} {{ migration_target }}
|
||||
{{ '--restart' if item.status == 'running' else '' }}
|
||||
{% if item.status == 'running' %}--restart{% endif %}
|
||||
--timeout {{ lxc_migrate_timeout }}
|
||||
loop: "{{ lxc_guests }}"
|
||||
when: live_migrate_fallback != 'skip'
|
||||
register: lxc_migrate_result
|
||||
changed_when: true
|
||||
|
||||
- name: "Drain | LXC | Log migration results"
|
||||
ansible.builtin.debug:
|
||||
msg: "LXC {{ item.item.vmid }} migrated to {{ migration_target }}"
|
||||
loop: "{{ lxc_migrate_result.results }}"
|
||||
when:
|
||||
- live_migrate_fallback != 'skip'
|
||||
- item.rc == 0
|
||||
loop: "{{ lxc_migrate_result.results | default([]) }}"
|
||||
when: item.rc is defined and item.rc == 0
|
||||
|
||||
- name: "Drain | {{ current_node }} drained successfully"
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
Node {{ current_node }} drained —
|
||||
{{ kvm_guests | length }} KVM + {{ lxc_guests | length }} LXC guests
|
||||
migrated to {{ migration_target }}
|
||||
|
||||
migrated to {{ migration_target }}
|
||||
Reference in New Issue
Block a user