forked from tim/k3s-ansible
ac1e3288c0
- Add serial to the reboot play so concurrent_reboots controls how many nodes reboot at a time, defaulting to 100% (reboot all at once) for backward compatibility - Add a per-node test_command that verifies the node is healthy after reboot - Add an optional wait_seconds_after_reboot pause between staggered batches so pods can settle before the next batch reboots - Document the new concurrent_reboots and wait_seconds_after_reboot variables Co-authored-by: Felix Seifert <mail@felix-seifert.com>
31 lines
1.0 KiB
YAML
31 lines
1.0 KiB
YAML
---
|
|
- name: Reboot k3s_cluster
|
|
hosts: k3s_cluster
|
|
gather_facts: true
|
|
|
|
# Stagger the reboot across the cluster when concurrent_reboots is set.
|
|
# Defaults to '100%' so the whole cluster reboots at once (backward compatible).
|
|
serial: "{{ concurrent_reboots | default('100%') }}"
|
|
|
|
tasks:
|
|
- name: >-
|
|
{{
|
|
'Reboot all nodes at once'
|
|
if (concurrent_reboots is not defined)
|
|
else 'Reboot nodes with concurrency of ' ~ concurrent_reboots
|
|
}}
|
|
become: true
|
|
ansible.builtin.reboot:
|
|
reboot_command: "{{ custom_reboot_command | default(omit) }}"
|
|
reboot_timeout: 300
|
|
test_command: >-
|
|
{{ 'kubectl get nodes' if 'master' in group_names else 'whoami' }}
|
|
|
|
- name: Optional wait before rebooting the next batch of nodes
|
|
ansible.builtin.pause:
|
|
seconds: "{{ wait_seconds_after_reboot | int }}"
|
|
when: >-
|
|
concurrent_reboots is defined and
|
|
wait_seconds_after_reboot is defined and
|
|
wait_seconds_after_reboot | int > 0
|