# Ansible Playbooks for k3s Cluster Installation This directory contains Ansible playbooks to install a k3s cluster with one master node and multiple worker nodes. ## Files Overview - `inventory.ini`: Contains the inventory of master and worker nodes - `main-playbook.yml`: Main playbook that orchestrates the entire installation - `install-k3s-master.yml`: Installs k3s on the master node - `install-k3s-workers.yml`: Installs k3s agents on worker nodes and joins them to the master - `verify-cluster.yml`: Verifies the cluster status after installation - `k3s.service.j2`: Template for the k3s master systemd service - `k3s-agent.service.j2`: Template for the k3s agent systemd service - `ansible.cfg`: Ansible configuration file ## Prerequisites - Ansible installed on the control machine - SSH access to all target machines with sudo privileges - Target machines running a supported Linux distribution ## Variables The playbooks use the following variables: - `master_ip`: IP address of the master node - `k3s_download_url`: URL to download the k3s binary - `k3s_token`: Token for joining worker nodes to the cluster ## Usage To run the complete installation: ```bash ansible-playbook -i inventory.ini main-playbook.yml ``` To run only the master installation: ```bash ansible-playbook -i inventory.ini install-k3s-master.yml ``` To run only the worker installation: ```bash ansible-playbook -i inventory.ini install-k3s-workers.yml ``` To verify the cluster status: ```bash ansible-playbook -i inventory.ini verify-cluster.yml ``` ## Configuration Edit the `inventory.ini` file to match your environment: - Update IP addresses of master and worker nodes - Update SSH credentials as needed