feat(ansible): add idempotency checks to skip already-upgraded control plane nodes

This commit is contained in:
2026-11-02 14:29:58 -05:00
parent 7d4d59f1ae
commit 0e1593dcae
2 changed files with 6 additions and 1 deletions

View File

@@ -23,12 +23,14 @@
curl -sfL "https://github.com/k3s-io/k3s/releases/download/${ENCODED_VER}/k3s-arm64" -o /usr/local/bin/k3s.new
chmod +x /usr/local/bin/k3s.new
mv /usr/local/bin/k3s.new /usr/local/bin/k3s
when: target_k3s_version not in pre_k3s_ver.stdout
register: k3s_download
- name: Restart K3s systemd service
ansible.builtin.systemd:
name: k3s
state: restarted
when: target_k3s_version not in pre_k3s_ver.stdout
- name: Wait for K3s systemd unit to report active
ansible.builtin.command: systemctl is-active k3s
@@ -37,6 +39,7 @@
retries: 20
delay: 4
changed_when: false
when: target_k3s_version not in pre_k3s_ver.stdout
- name: Wait for upgraded node to report Ready in Kubernetes
ansible.builtin.command: kubectl get node {{ inventory_hostname }} -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
@@ -46,6 +49,7 @@
retries: 30
delay: 5
changed_when: false
when: target_k3s_version not in pre_k3s_ver.stdout
- name: Query post-upgrade K3s version
ansible.builtin.command: k3s --version
@@ -57,8 +61,9 @@
that:
- target_k3s_version in post_k3s_ver.stdout
fail_msg: "Post-upgrade version does not match target {{ target_k3s_version }}"
success_msg: "{{ inventory_hostname }} successfully upgraded to {{ target_k3s_version }}"
success_msg: "{{ inventory_hostname }} is verified on {{ target_k3s_version }}"
- name: Settle etcd cluster state
ansible.builtin.pause:
seconds: 10
when: target_k3s_version not in pre_k3s_ver.stdout

Binary file not shown.