-
Notifications
You must be signed in to change notification settings - Fork 1
/
vagrant.sh
executable file
·23 lines (18 loc) · 988 Bytes
/
vagrant.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
set -euo pipefail
pp='\033[0;35m' #purple
nc='\033[0m\n' #no color + newline
if [ "${VAGRANT_TRIGGER:-}" == "false" ]
then
printf "%bVAGRANT_TRIGGER is false. Skipping provisioning.%b" "${pp}" "${nc}"
else
printf "%b# prepping vagrant VMs%b" "${pp}" "${nc}"
ansible-playbook vagrant-site.yml
printf "%b# installing rke2-ansible via controller VM%b" "${pp}" "${nc}"
vagrant ssh controller -c 'cd ./rke2-ansible && ansible-playbook site.yml -v'
printf "%b# saving master-01 kubeconfig to /tmp/rke2-ansible.yaml%b" "${pp}" "${nc}"
ansible ,master-01 -b -m fetch -a 'src=/etc/rancher/rke2/rke2.yaml dest=/tmp/rke2-ansible.yaml flat=yes'
printf "%b# accessing master-01 to check nodes status ready%b" "${pp}" "${nc}"
vagrant ssh master-01 -c 'sudo /var/lib/rancher/rke2/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml wait node --all --for condition=ready --timeout=300s'
printf "%b## FINISHED ##%b" "${pp}" "${nc}"
fi