23 lines
No EOL
797 B
YAML
23 lines
No EOL
797 B
YAML
---
|
|
- name: Install k3s on node3
|
|
hosts: node3
|
|
become: true
|
|
gather_facts: no
|
|
vars:
|
|
ansible_user: ansible
|
|
ansible_ssh_private_key_file: ~/.ssh/ansible
|
|
tasks:
|
|
- name: Install k3s using direct command
|
|
raw: |
|
|
if ! command -v k3s &> /dev/null; then
|
|
# Get token from node1
|
|
TOKEN=$(ssh -o StrictHostKeyChecking=no -i ~/.ssh/ansible ansible@10.0.101.211 "sudo cat /var/lib/rancher/k3s/server/node-token" 2>/dev/null)
|
|
if [ -n "$TOKEN" ]; then
|
|
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION='v1.28.4+k3s1' K3S_URL='https://10.0.101.211:6443' K3S_TOKEN="$TOKEN" sh -
|
|
else
|
|
echo "Failed to get token from master"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "k3s already installed"
|
|
fi |