Skip to content

Commit c6b6d61

Browse files
automate persistent volume creation
1 parent 45399bf commit c6b6d61

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

Vagrantfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,20 @@ Vagrant.configure("2") do |config|
130130
def provision_rancher_server(m)
131131
provision_rancherd m, "server"
132132
m.vm.provision "shell", inline: <<-SHELL
133+
function retry_until_success() {
134+
local command="$1"
135+
local message="${2:-retrying $1}"
136+
while ! eval "$command"; do sleep 5; echo "$message"; done
137+
}
133138
snap install kubectl --classic && bash <(curl -sL https://www.eclipse.org/che/chectl/) &&
134139
systemctl enable rancherd-server.service && systemctl start rancherd-server.service &&
135-
while ! nc -z localhost 443; do sleep 5; echo waiting for rancher-server; done &&
136-
while ! rancherd reset-admin --password cloud; do sleep 5; echo retrying ui init; done &&
137-
mkdir /home/vagrant/.kube && cp /etc/rancher/rke2/rke2.yaml /home/vagrant/.kube/config &&
138-
chown -R vagrant:vagrant /home/vagrant
140+
retry_until_success "nc -z localhost 443" "waiting for rancher-server" &&
141+
retry_until_success "rancherd reset-admin --password cloud" "retrying ui init" &&
142+
mkdir /home/vagrant/.kube && mkdir /root/.kube/ &&
143+
cp /etc/rancher/rke2/rke2.yaml /home/vagrant/.kube/config &&
144+
cp /etc/rancher/rke2/rke2.yaml /root/.kube/config &&
145+
chown -R vagrant:vagrant /home/vagrant &&
146+
kubectl apply -f /home/vagrant/rancher/
139147
SHELL
140148
end
141149
def provision_rancher_agent(m)

0 commit comments

Comments
 (0)