forked from hughobrien/k3os-hetzner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision-local.sh
executable file
·52 lines (46 loc) · 1.2 KB
/
provision-local.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
set -xeuo pipefail
node_idx="$1"
node_name="$2"
node_ipv4_public="$3"
node_ipv4_private="$4"
node_cidr_private="$5"
node_location="$6"
node_datacenter="$7"
node_server_type="$8"
k3os_ver="$9"
cluster_master="${10}"
cluster_secret="${11}"
rescue_user=root
ssh_key=secrets/ssh-terraform
script_name=provision-remote.sh
script_dest="/tmp/${script_name}"
ssh_opts="-o StrictHostKeyChecking=no"
# cd to script dir
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" >&/dev/null && pwd)"
# remove existing ssh keys
ssh-keygen -R "$node_ipv4_public"
set +e
response=""
while [ "$response" != "rescue" ]; do
sleep 5
response=$(ssh -i "$ssh_key" "$ssh_opts" "${rescue_user}@${node_ipv4_public}" hostname)
done
set -e
scp "$ssh_opts" -i "$ssh_key" "$script_name" "${rescue_user}@${node_ipv4_public}:${script_dest}"
ssh "$ssh_opts" -i "$ssh_key" "${rescue_user}@${node_ipv4_public}" \
hosting="${hosting:-""}" \
"$script_dest" \
"$node_idx" \
"$node_name" \
"$node_ipv4_public" \
"$node_ipv4_private" \
"$node_cidr_private" \
"$node_location" \
"$node_datacenter" \
"$node_server_type" \
"$k3os_ver" \
"$cluster_master" \
"$cluster_secret" || true
# remove rescue ssh key
ssh-keygen -R "$node_ipv4_public"