Files
ansible/roles/k3s_agent
Tuan-Dat Tran 2882abfc0b Added README.md for roles
Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
2025-07-27 16:40:46 +02:00
..
2024-09-20 16:57:59 +02:00
2025-07-27 16:40:46 +02:00

K3s Agent Ansible Role

This Ansible role installs and configures a K3s agent on a node.

Role Variables

  • k3s.loadbalancer.default_port: The port for the K3s load balancer. Defaults to 6443.
  • k3s_token: The token for joining the K3s cluster. This is a required variable.
  • hostvars['k3s-loadbalancer'].ansible_default_ipv4.address: The IP address of the K3s load balancer. This is a required variable.

Tasks

The main tasks are in tasks/main.yml and tasks/installation.yml.

  • installation.yml:
    • Installs qemu-guest-agent.
    • Checks if K3s is already installed.
    • Downloads the K3s installation script to /tmp/k3s_install.sh.
    • Installs K3s as an agent, connecting to the master.

Handlers

The main handlers are in handlers/main.yml.

  • Restart k3s: Restarts the k3s service.

Usage

Here is an example of how to use this role in a playbook:

---
- hosts: k3s_agents
  roles:
    - role: k3s_agent
      vars:
        k3s_token: "your_k3s_token"
        k3s.loadbalancer.default_port: 6443