40 lines
1.0 KiB
Markdown
40 lines
1.0 KiB
Markdown
# 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:
|
|
|
|
```yaml
|
|
---
|
|
- hosts: k3s_agents
|
|
roles:
|
|
- role: k3s_agent
|
|
vars:
|
|
k3s_token: "your_k3s_token"
|
|
k3s.loadbalancer.default_port: 6443
|
|
```
|