44 lines
1.3 KiB
YAML
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_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_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 |