homelab/build/config/ansible/roles/k3s_node/tasks/main.yml
Russell Seymour 1250c9cef6
Some checks are pending
deploy / deploy (push) Waiting to run
Initial checkin of code for managing homelab
2026-08-24 20:52:36 +01:00

24 lines
925 B
YAML

---
# Converges one node of the cluster: the same prep either way, then branch on
# which k3s role it plays. k3s_node_role is set per group, not per host — see
# inventory/group_vars/k3s_control_plane.yml (server) and k3s_workers.yml
# (agent) — so adding a fifth Pi later is a hosts.yml edit, not a role change.
- name: Validate k3s_node_role
ansible.builtin.assert:
that: k3s_node_role in ['server', 'agent']
fail_msg: >-
k3s_node_role is '{{ k3s_node_role }}'; expected 'server' or 'agent'.
Check inventory/group_vars/k3s_control_plane.yml and k3s_workers.yml.
quiet: true
- name: Prepare the node for k3s
ansible.builtin.include_tasks: prep.yml
- name: Install the k3s server (control plane)
ansible.builtin.include_tasks: server.yml
when: k3s_node_role == 'server'
- name: Install the k3s agent (worker)
ansible.builtin.include_tasks: agent.yml
when: k3s_node_role == 'agent'