useradd -mU ansible
usermod -aG sudo ansible
mkdir /home/ansible/.ssh
chmod 700 /home/ansible/.ssh
echo '# SSH keys go here' >> /home/ansible/.ssh/authorized_keys
chmod 600 /home/ansible/.ssh/authorized_keys
chown -R ansible:ansible /home/ansible/.ssh
echo "ansible ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
mkdir /root/.ssh
chmod 700 /root/.ssh
echo '# SSH keys go here' >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
Deployment environment must have Ansible 2.4.0+ Master and nodes must have passwordless SSH access
- create
inventory/pi-cluster.ini
containing master and node hosts. For example:
[master]
192.168.0.10
[node]
192.168.0.[11:12]
[k3s_cluster:children]
master
node
-
edit
k3s-cluster/group_vars/all.yml
to change cluster variables -
run playbook
ansible-playbook k3s-cluster/site.yml -i inventory/pi-cluster.ini
- copy cluster config to get access
scp ansible@master_ip:~/.kube/config ~/.kube/config