How lablabs/ansible-role-rke2 works
Project type and purpose
• This is an open-source Ansible Role named “ansible-role-rke2” whose purpose is to automate the installation and configuration of RKE2 Kubernetes clusters in various modes (single node, multi-node cluster, HA cluster, air-gapped).
• The README confirms that it deploys the RKE2 control plane (masters/servers) and agents (workers), configures HA using Keepalived or Kube-VIP, and supports rolling upgrades, CIS benchmarking, custom manifests, etc.
File structure
• Top-level CI and governance:
• .github/ (workflows for CI, linting, release drafting, issue/PR templates)
• molecule/ (integration tests in scenarios: cluster, default, ha_cluster, ha_cluster_kubevip)
• requirements.yml, .pre-commit-config.yaml
• Role implementation:
• defaults/main.yml – default variables and feature flags
• vars/main.yml – supplementary variables
• tasks/main.yml + sub-tasks (rke2, cis, ha, rolling_restart, summary, etc.)
• handlers/main.yml – handler definitions for service restarts or notifications
• templates/ – Jinja2 templates for config.yaml, registries.yaml, keepalived, kube-vip manifests, shell checks
• meta/main.yml & argument_specs.yml – role metadata and parameter specs
• Molecule scenarios invoke the role with different inventories and converge/verify steps.
Key architecture insights from README
• The role uses inventory groups (masters, workers, children of k8s_cluster) to determine node type.
• It installs RKE2 via tarball, applies tokens, sets up networking, CNI, optional load-balancer with keepalived or kube-vip.
• Supports air-gap via artifact download/copy/exists, snapshots/restore, custom manifests, taints, proxies, etc.