fix: restore k3s agent bootstrap
Some checks failed
Deploy Cluster / Terraform (push) Successful in 49s
Deploy Cluster / Ansible (push) Failing after 18m16s

This commit is contained in:
2026-03-20 01:50:16 +00:00
parent 3e41f71b1b
commit 5bd4c41c2d
2 changed files with 35 additions and 11 deletions

View File

@@ -3,4 +3,4 @@ k3s_version: latest
k3s_server_url: "" k3s_server_url: ""
k3s_token: "" k3s_token: ""
k3s_node_ip: "" k3s_node_ip: ""
k3s_kubelet_cloud_provider_external: true k3s_kubelet_cloud_provider_external: false

View File

@@ -12,6 +12,9 @@
when: not k3s_agent_binary.stat.exists when: not k3s_agent_binary.stat.exists
- name: Install k3s agent - name: Install k3s agent
when: not k3s_agent_binary.stat.exists
block:
- name: Run k3s agent install
environment: environment:
INSTALL_K3S_VERSION: "{{ k3s_version if k3s_version != 'latest' else '' }}" INSTALL_K3S_VERSION: "{{ k3s_version if k3s_version != 'latest' else '' }}"
K3S_URL: "{{ k3s_server_url }}" K3S_URL: "{{ k3s_server_url }}"
@@ -22,7 +25,28 @@
{% if k3s_kubelet_cloud_provider_external | bool %}--kubelet-arg=cloud-provider=external{% endif %} {% if k3s_kubelet_cloud_provider_external | bool %}--kubelet-arg=cloud-provider=external{% endif %}
args: args:
creates: /usr/local/bin/k3s-agent creates: /usr/local/bin/k3s-agent
when: not k3s_agent_binary.stat.exists rescue:
- name: Show k3s-agent service status after failed install
command: systemctl status k3s-agent --no-pager
register: k3s_agent_status_after_install
changed_when: false
failed_when: false
- name: Show recent k3s-agent logs after failed install
command: journalctl -u k3s-agent -n 120 --no-pager
register: k3s_agent_journal_after_install
changed_when: false
failed_when: false
- name: Fail with k3s-agent diagnostics
fail:
msg: |
k3s agent install failed on {{ inventory_hostname }}.
Service status:
{{ k3s_agent_status_after_install.stdout | default('n/a') }}
Recent logs:
{{ k3s_agent_journal_after_install.stdout | default('n/a') }}
- name: Wait for k3s agent to be ready - name: Wait for k3s agent to be ready
command: systemctl is-active k3s-agent command: systemctl is-active k3s-agent