--- - hosts: proxmox strategy: linear vars: ansible_command_timeout: 600 # Increased timeout for potential long-running updates and reboots ansible_ssh_extra_args: '-o StrictHostKeyChecking=no' pre_tasks: - name: Enter node maintenance mode command: pvecm node-maintenance become: yes register: maintenance_mode_result changed_when: maintenance_mode_result.rc == 0 - name: Verify SSH connectivity ping: register: ssh_connection_check ignore_errors: yes - name: Fail if SSH connection is not working fail: msg: "Unable to establish SSH connection to the host" when: ssh_connection_check.failed tasks: - name: Update apt cache apt: update_cache: yes become: yes - name: Upgrade all packages apt: upgrade: yes autoremove: yes autoclean: yes become: yes - name: Wait for 5 seconds before rebooting wait_for: timeout: 5 - hosts: 172.16.30.41 # First host vars: ansible_ssh_extra_args: '-o StrictHostKeyChecking=no' tasks: - name: Reboot first host reboot: reboot_timeout: 300 # 5 minutes timeout for host to come back online msg: "Rebooting for system updates" become: yes - name: Wait 30 seconds before next reboot wait_for: timeout: 30 - name: Exit node maintenance mode command: pvecm node-resume become: yes register: maintenance_exit_result changed_when: maintenance_exit_result.rc == 0 - hosts: 172.16.30.42 # Second host vars: ansible_ssh_extra_args: '-o StrictHostKeyChecking=no' tasks: - name: Reboot second host reboot: reboot_timeout: 300 msg: "Rebooting for system updates" become: yes - name: Wait 30 seconds before next reboot wait_for: timeout: 30 - name: Exit node maintenance mode command: pvecm node-resume become: yes register: maintenance_exit_result changed_when: maintenance_exit_result.rc == 0 - hosts: 172.16.30.43 # Third host vars: ansible_ssh_extra_args: '-o StrictHostKeyChecking=no' tasks: - name: Reboot third host reboot: reboot_timeout: 300 msg: "Rebooting for system updates" become: yes - name: Exit node maintenance mode command: pvecm node-resume become: yes register: maintenance_exit_result changed_when: maintenance_exit_result.rc == 0