renamed inventory file

restructured to support more generic k3s single host or cluster deployment
This commit is contained in:
Radar231 2023-01-07 20:51:52 +00:00
parent 7b3341cc90
commit c6fe8607f5
2 changed files with 18 additions and 30 deletions

View File

@ -13,20 +13,5 @@ all:
ansible_host: 192.168.122.232
node3:
ansible_host: 192.168.122.233
children:
master:
hosts:
node1:
workers:
hosts:
node2:
node3:
# Global variables
vars:
# Switch to control whether we are creating a cluster, or just
# deploying to a single host
do_cluster: true
# Minimum hosts for our cluster
minhosts: "3"
# EOF

33
k3s.yml
View File

@ -3,29 +3,29 @@
#
# This is the top level playbook for the 'k3s' role.
#
# This role will install a k3s cluster to three or more target hosts.
# 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 role requires at least three target hosts, previously deployed. Each
# host should have at least 4GB of RAM and at least a 20GB disk.
# 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.
#
# NOTE: If you are installing in a proxied environment, make sure that you
# have either 'HTTP_PROXY' or 'HTTPS_PROXY' (case is not important)
# defined in your env variables (usually via ~/.bashrc). In addition
# to that, you also need to have 'NO_PROXY' (again, case is not
# important) also defined. This is where the k3s installer will
# retrieve the relevant proxy configuration values.
#
###########################################################################
#
# This playbook can be run using the following command line;
#
# ansible-playbook -i <inventory file> -e "username=<username>" k3s.yml
# ansible-playbook -i <inventory file> -e "k3s_user=<username>" k3s.yml
#
# ie,
# ansible-playbook -i k3s_inventory.yml -e "username=someuser" k3s.yml
# ansible-playbook -i ex-inv_k3s.yml -e "k3s_user=someuser" k3s.yml
#
###########################################################################
@ -37,12 +37,15 @@
- role: k3s
vars:
# Calculate the number of target hosts
numhosts: "{{ groups['all'] | length }}"
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,
# username: someuser
# k3s_user: someuser
#
# Default is to apply the playbook against the root user
username: "root"
k3s_user: "root"
# EOF