fix: add k3s reset logic for primary control plane
Some checks failed
Deploy Cluster / Terraform (push) Successful in 39s
Deploy Cluster / Ansible (push) Failing after 4m19s

This commit is contained in:
2026-03-21 16:10:17 +00:00
parent d4fd43e2f5
commit 8d1f9f4944

View File

@@ -28,27 +28,22 @@
stat:
path: /usr/local/bin/k3s-uninstall.sh
register: k3s_uninstall_script
when:
- not (k3s_primary | default(false))
- k3s_install_needed
when: k3s_install_needed
- name: Reset broken secondary k3s install before rejoin
- name: Reset broken k3s install before reinstall
command: /usr/local/bin/k3s-uninstall.sh
when:
- not (k3s_primary | default(false))
- k3s_install_needed
- k3s_uninstall_script.stat.exists
- name: Remove stale k3s data on secondary
- name: Remove stale k3s data
file:
path: "{{ item }}"
state: absent
loop:
- /etc/rancher/k3s
- /var/lib/rancher/k3s
when:
- not (k3s_primary | default(false))
- k3s_install_needed
when: k3s_install_needed
- name: Download k3s install script
get_url:
@@ -58,19 +53,22 @@
when: k3s_install_needed
- name: Install k3s server (primary)
environment:
INSTALL_K3S_VERSION: "{{ k3s_version if k3s_version != 'latest' else '' }}"
K3S_TOKEN: "{{ k3s_token }}"
command: >-
/tmp/install-k3s.sh server
--cluster-init
--advertise-address={{ k3s_primary_ip }}
--node-ip={{ k3s_node_ip }}
--tls-san={{ k3s_primary_ip }}
--tls-san={{ k3s_primary_public_ip }}
when:
- k3s_install_needed
- k3s_primary | default(false)
environment:
INSTALL_K3S_VERSION: "{{ k3s_version if k3s_version != 'latest' else '' }}"
K3S_TOKEN: "{{ k3s_token }}"
command: >-
/tmp/install-k3s.sh server
--cluster-init
--advertise-address={{ k3s_primary_ip }}
--node-ip={{ k3s_node_ip }}
--tls-san={{ k3s_primary_ip }}
--tls-san={{ k3s_primary_public_ip }}
{% if k3s_disable_embedded_ccm | bool %}--disable-cloud-controller{% endif %}
{% if k3s_disable_servicelb | bool %}--disable=servicelb{% endif %}
{% if k3s_kubelet_cloud_provider_external | bool %}--kubelet-arg=cloud-provider=external{% endif %}
when:
- k3s_install_needed
- k3s_primary | default(false)
- name: Install k3s server (secondary)
when:
@@ -86,6 +84,9 @@
--server https://{{ k3s_primary_ip }}:6443
--advertise-address={{ k3s_node_ip }}
--node-ip={{ k3s_node_ip }}
{% if k3s_disable_embedded_ccm | bool %}--disable-cloud-controller{% endif %}
{% if k3s_disable_servicelb | bool %}--disable=servicelb{% endif %}
{% if k3s_kubelet_cloud_provider_external | bool %}--kubelet-arg=cloud-provider=external{% endif %}
register: secondary_install
rescue: