fix: Check for k3s service instead of binary for proper HA join detection
Some checks failed
Deploy Cluster / Terraform (push) Successful in 19s
Deploy Cluster / Ansible (push) Failing after 8m5s

This commit is contained in:
2026-02-28 23:16:39 +00:00
parent e26fdfe614
commit 691b3ed316

View File

@@ -1,25 +1,28 @@
---
- name: Check if k3s is already installed
- name: Check if k3s service exists
stat:
path: /usr/local/bin/k3s
register: k3s_binary
path: /etc/systemd/system/k3s.service
register: k3s_service
- name: Check if k3s is part of cluster
stat:
path: /var/lib/rancher/k3s/server/node-token
register: k3s_cluster_member
- name: Download k3s install script
get_url:
url: https://get.k3s.io
dest: /tmp/install-k3s.sh
mode: "0755"
when: not k3s_binary.stat.exists
when: not k3s_service.stat.exists
- 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
args:
creates: /usr/local/bin/k3s
when:
- not k3s_binary.stat.exists
- not k3s_service.stat.exists
- k3s_primary | default(false)
- name: Install k3s server (secondary)
@@ -27,10 +30,8 @@
INSTALL_K3S_VERSION: "{{ k3s_version if k3s_version != 'latest' else '' }}"
K3S_TOKEN: "{{ k3s_token }}"
command: /tmp/install-k3s.sh server --server https://{{ k3s_primary_ip }}:6443
args:
creates: /usr/local/bin/k3s
when:
- not k3s_binary.stat.exists
- not k3s_service.stat.exists
- not (k3s_primary | default(false))
- name: Wait for k3s to be ready