playbook_k3s/k3s.yml

52 lines
1.6 KiB
YAML

---
###########################################################################
#
# This is the top level playbook for the 'k3s' role.
#
# This playbook will install k3s to one or more hosts. If there are multiple
# hosts the first inventory host will be the master node, and all others will
# be worker nodes.
#
# This playbook will only setup simple clusters with a single master node. To
# setup an HA cluster with multiple master nodes, please refer to the following
# URL and perform the cluster installation manually.
#
# * https://docs.k3s.io/installation/ha-embedded
#
# Each host should have at least 4GB of RAM and at least a 20GB disk.
#
# It is also assumed that the user running the playbook has SSH key access
# set up for the root user on the target hosts.
#
###########################################################################
#
# This playbook can be run using the following command line;
#
# ansible-playbook -i <inventory file> -e "k3s_user=<username>" k3s.yml
#
# ie,
# ansible-playbook -i ex-inv_k3s.yml -e "k3s_user=someuser" k3s.yml
#
###########################################################################
- hosts: all
gather_facts: true
remote_user: root
roles:
- role: k3s
vars:
# Calculate the number of target hosts
numhosts: "{{ ansible_play_hosts | length }}"
master_host: "{{ ansible_play_hosts[0] }}"
master_ip: "{{ hostvars[master_host].ansible_host }}"
# Set the following variable as required
# ie,
# k3s_user: someuser
#
# Default is to apply the playbook against the root user
k3s_user: "root"
# EOF