--- # ============================================================================= # proxmox_reboot.yml # Controlled rolling reboot of Proxmox cluster nodes. # Drains guests before rebooting, waits for rejoin, optionally restores. # # Use cases: # - Apply kernel updates that require a reboot # - Scheduled maintenance reboots # - Hardware changes requiring a restart # # Variables: # reboot_order — ordered list of nodes to reboot (default: upgrade_order) # reboot_reason — logged message explaining the reboot # migration_restore — return VMs to origin after reboot (default: false) # drain_target_strategy — resources | explicit (default: resources) # # Usage: # # Rolling reboot all nodes # ansible-playbook proxmox_reboot.yml # # # Reboot a single node # ansible-playbook proxmox_reboot.yml -e "reboot_order=[pm-node-02]" # # # Reboot and restore VMs to origin # ansible-playbook proxmox_reboot.yml -e "migration_restore=true" # ============================================================================= - name: "Proxmox | Controlled Rolling Reboot" hosts: proxmox_cluster gather_facts: true run_once: true vars: reboot_order: "{{ upgrade_order | default(groups['proxmox_cluster'] | sort) }}" reboot_reason: "Scheduled maintenance reboot" migration_restore: false reboot_timeout: 600 node_rejoin_timeout: 300 node_rejoin_retries: 30 node_rejoin_delay: 10 pre_tasks: - name: "Reboot | Log operation" ansible.builtin.debug: msg: >- Proxmox rolling reboot — client={{ client_name | default('Unknown') }} nodes={{ reboot_order | join(', ') }} reason={{ reboot_reason }} restore={{ migration_restore }} roles: - role: proxmox_preflight tasks: - name: "Reboot | Rolling reboot — cluster mode" ansible.builtin.include_tasks: tasks/proxmox_reboot_node_loop.yml loop: "{{ reboot_order }}" loop_control: loop_var: current_node label: "{{ current_node }}" when: proxmox_is_cluster - name: "Reboot | Standalone | Reboot node" ansible.builtin.reboot: reboot_timeout: "{{ reboot_timeout }}" msg: "{{ reboot_reason }}" pre_reboot_delay: 5 post_reboot_delay: 15 when: not proxmox_is_cluster - name: "Reboot | Complete" ansible.builtin.debug: msg: "✓ Rolling reboot complete for {{ client_name | default('cluster') }}."