fix: loop_var under loop_control in drain.yml and restore.yml

This commit is contained in:
Semaphore
2026-03-14 14:25:24 -07:00
parent e771f6d9a9
commit a19fe2ce5d
8 changed files with 50 additions and 11 deletions

View File

@@ -28,4 +28,3 @@ apt_autoremove: true
migrate_exclude_tags: migrate_exclude_tags:
- nomigrate - nomigrate
- pinned - pinned

View File

@@ -136,7 +136,8 @@
when: not migration_bulk | bool when: not migration_bulk | bool
include_tasks: migrate_guest.yml include_tasks: migrate_guest.yml
loop: "{{ migration_plan | rejectattr('needs_fallback') | list + migration_plan | selectattr('needs_fallback') | rejectattr('needs_fallback' if live_migrate_fallback == 'skip' else 'nonexistent') | list }}" loop: "{{ migration_plan | rejectattr('needs_fallback') | list + migration_plan | selectattr('needs_fallback') | rejectattr('needs_fallback' if live_migrate_fallback == 'skip' else 'nonexistent') | list }}"
loop_var: guest loop_control:
loop_var: guest
- name: Drain | Migrate guests (bulk — fire all at once) - name: Drain | Migrate guests (bulk — fire all at once)
when: migration_bulk | bool when: migration_bulk | bool
@@ -154,7 +155,8 @@
validate_certs: false validate_certs: false
register: bulk_migration_tasks register: bulk_migration_tasks
loop: "{{ migration_plan | rejectattr('needs_fallback') | list }}" loop: "{{ migration_plan | rejectattr('needs_fallback') | list }}"
loop_var: guest loop_control:
loop_var: guest
delegate_to: localhost delegate_to: localhost
- name: Drain | Bulk | Wait for all migrations to complete - name: Drain | Bulk | Wait for all migrations to complete
@@ -181,6 +183,6 @@
- name: Drain | Bulk | Handle fallback guests sequentially - name: Drain | Bulk | Handle fallback guests sequentially
include_tasks: migrate_guest.yml include_tasks: migrate_guest.yml
loop: "{{ migration_plan | selectattr('needs_fallback') | list }}" loop: "{{ migration_plan | selectattr('needs_fallback') | list }}"
loop_var: guest loop_control:
loop_var: guest
when: live_migrate_fallback != 'skip' when: live_migrate_fallback != 'skip'

View File

@@ -114,4 +114,3 @@
live migrated to {{ migration_targets | first }} live migrated to {{ migration_targets | first }}
{% endif %} {% endif %}
delegate_to: localhost delegate_to: localhost

View File

@@ -38,4 +38,3 @@
- name: "Node {{ current_node }} | Complete" - name: "Node {{ current_node }} | Complete"
ansible.builtin.debug: ansible.builtin.debug:
msg: "━━━ Node {{ current_node }} upgrade complete ━━━" msg: "━━━ Node {{ current_node }} upgrade complete ━━━"

View File

@@ -73,4 +73,3 @@
msg: "Cluster health check passed — all nodes online, quorum OK{{ ', CEPH checked' if ceph_enabled else '' }}" msg: "Cluster health check passed — all nodes online, quorum OK{{ ', CEPH checked' if ceph_enabled else '' }}"
delegate_to: localhost delegate_to: localhost
run_once: true run_once: true

View File

@@ -0,0 +1,42 @@
---
# =============================================================================
# proxmox_upgrade.yml
# =============================================================================
# Rolling Proxmox cluster upgrade playbook.
# Runs on the first node in upgrade_order — all other nodes are handled
# via API calls and delegate_to from within the role.
#
# Usage:
# ansible-playbook playbooks/proxmox_upgrade.yml \
# -i inventories/client_local_eng/hypervisor_hosts.yml
#
# Override migration behaviour:
# -e migration_bulk=true
# -e live_migrate_fallback=skip
# -e migration_restore=true
#
# Dry run (check mode — no changes):
# --check
# =============================================================================
- name: Proxmox Rolling Upgrade
hosts: proxmox_cluster
gather_facts: true
serial: 1
run_once: true
pre_tasks:
- name: Confirm upgrade_order is defined
ansible.builtin.fail:
msg: "upgrade_order must be defined in hypervisor_hosts.yml"
when: upgrade_order is not defined or upgrade_order | length == 0
- name: Log upgrade targets
ansible.builtin.debug:
msg: >-
Proxmox upgrade starting for {{ client_name }} ({{ client_id }})
Nodes: {{ upgrade_order | join(', ') }}
API: https://{{ api_host }}:{{ api_port }}
roles:
- proxmox_upgrade

View File

@@ -33,7 +33,8 @@
validate_certs: false validate_certs: false
register: restore_task register: restore_task
loop: "{{ migration_plan | rejectattr('needs_fallback') | list }}" loop: "{{ migration_plan | rejectattr('needs_fallback') | list }}"
loop_var: guest loop_control:
loop_var: guest
delegate_to: localhost delegate_to: localhost
- name: Restore | Wait for all restore migrations to complete - name: Restore | Wait for all restore migrations to complete
@@ -60,4 +61,3 @@
- name: Restore | Complete - name: Restore | Complete
ansible.builtin.debug: ansible.builtin.debug:
msg: "All guests restored to {{ current_node }}" msg: "All guests restored to {{ current_node }}"

View File

@@ -92,4 +92,3 @@
Node {{ current_node }} upgrade complete — Node {{ current_node }} upgrade complete —
{{ apt_upgrade_result.stdout_lines | select('match', '.*upgraded.*') | list | first | default('packages updated') }} {{ apt_upgrade_result.stdout_lines | select('match', '.*upgraded.*') | list | first | default('packages updated') }}
{{ '— rebooted' if reboot_required.stat.exists else '— no reboot needed' }} {{ '— rebooted' if reboot_required.stat.exists else '— no reboot needed' }}