Nik Afiq 12718203ac
Some checks failed
validate / lint (push) Failing after 1s
fix: k3s-agent label/taint tasks use undefined ansible_hostname
ansible.cfg sets inject_facts_as_vars: False repo-wide (the ollama role
already follows this via ansible_facts['system']), but these two tasks
referenced the bare ansible_hostname magic var, which doesn't exist under
that setting. Surfaced today as a hard failure re-running setup-gpu-node -
previously latent since these nodes' labels/taints were already correct
from whenever they last applied cleanly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 00:13:22 +09:00

44 lines
1.3 KiB
YAML

---
# Part of role: k3s-agent
# Called by: ansible/playbooks/join-debian-agent.yaml
# ansible/playbooks/setup-gpu-node.yaml
# Description: Installs K3s in agent mode, joins the cluster, labels and taints the node.
- name: Download and install K3s agent
ansible.builtin.shell:
cmd: >
curl -sfL https://get.k3s.io |
INSTALL_K3S_VERSION={{ k3s_version }}
K3S_URL={{ k3s_server_url }}
K3S_TOKEN={{ k3s_node_token }}
sh -
creates: /usr/local/bin/k3s
- name: Ensure K3s agent service is running
ansible.builtin.service:
name: k3s-agent
state: started
enabled: true
become: true
- name: Apply node labels
ansible.builtin.shell:
cmd: >
k3s kubectl label node {{ ansible_facts['hostname'] }}
{{ item.key }}={{ item.value }} --overwrite
loop: "{{ k3s_node_labels | dict2items }}"
delegate_to: minisforum
become: true
changed_when: false
when: k3s_node_labels is defined and k3s_node_labels | length > 0
- name: Apply node taints
ansible.builtin.shell:
cmd: >
k3s kubectl taint node {{ ansible_facts['hostname'] }}
{{ item }} --overwrite
loop: "{{ k3s_node_taints }}"
delegate_to: minisforum
become: true
changed_when: false
when: k3s_node_taints is defined and k3s_node_taints | length > 0