feat(ansible): add idempotency checks to skip already-upgraded control plane nodes
This commit is contained in:
@@ -23,12 +23,14 @@
|
|||||||
curl -sfL "https://github.com/k3s-io/k3s/releases/download/${ENCODED_VER}/k3s-arm64" -o /usr/local/bin/k3s.new
|
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
|
chmod +x /usr/local/bin/k3s.new
|
||||||
mv /usr/local/bin/k3s.new /usr/local/bin/k3s
|
mv /usr/local/bin/k3s.new /usr/local/bin/k3s
|
||||||
|
when: target_k3s_version not in pre_k3s_ver.stdout
|
||||||
register: k3s_download
|
register: k3s_download
|
||||||
|
|
||||||
- name: Restart K3s systemd service
|
- name: Restart K3s systemd service
|
||||||
ansible.builtin.systemd:
|
ansible.builtin.systemd:
|
||||||
name: k3s
|
name: k3s
|
||||||
state: restarted
|
state: restarted
|
||||||
|
when: target_k3s_version not in pre_k3s_ver.stdout
|
||||||
|
|
||||||
- name: Wait for K3s systemd unit to report active
|
- name: Wait for K3s systemd unit to report active
|
||||||
ansible.builtin.command: systemctl is-active k3s
|
ansible.builtin.command: systemctl is-active k3s
|
||||||
@@ -37,6 +39,7 @@
|
|||||||
retries: 20
|
retries: 20
|
||||||
delay: 4
|
delay: 4
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
when: target_k3s_version not in pre_k3s_ver.stdout
|
||||||
|
|
||||||
- name: Wait for upgraded node to report Ready in Kubernetes
|
- 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}'
|
ansible.builtin.command: kubectl get node {{ inventory_hostname }} -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
|
||||||
@@ -46,6 +49,7 @@
|
|||||||
retries: 30
|
retries: 30
|
||||||
delay: 5
|
delay: 5
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
when: target_k3s_version not in pre_k3s_ver.stdout
|
||||||
|
|
||||||
- name: Query post-upgrade K3s version
|
- name: Query post-upgrade K3s version
|
||||||
ansible.builtin.command: k3s --version
|
ansible.builtin.command: k3s --version
|
||||||
@@ -57,8 +61,9 @@
|
|||||||
that:
|
that:
|
||||||
- target_k3s_version in post_k3s_ver.stdout
|
- target_k3s_version in post_k3s_ver.stdout
|
||||||
fail_msg: "Post-upgrade version does not match target {{ target_k3s_version }}"
|
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
|
- name: Settle etcd cluster state
|
||||||
ansible.builtin.pause:
|
ansible.builtin.pause:
|
||||||
seconds: 10
|
seconds: 10
|
||||||
|
when: target_k3s_version not in pre_k3s_ver.stdout
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user