forked from contiv/install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlegacy_swarm_test.sh
56 lines (47 loc) · 1.7 KB
/
legacy_swarm_test.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
53
54
55
56
#!/bin/bash
set -euo pipefail
# Get the master node IP from the yml file generated by vagrant
contiv_master=$(grep -B 3 master cluster/.cfg_legacy-swarm.yaml | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}" | xargs)
node_os=${CONTIV_NODE_OS:-"centos"}
# Default user is vagrant for non-ubuntu and ubuntu for ubuntu boxes.
if [ "$node_os" == "ubuntu" ]; then
def_user="ubuntu"
def_key="$HOME/.ssh/id_rsa"
else
def_user="vagrant"
def_key=""
fi
user=${CONTIV_SSH_USER:-"$def_user"}
# If BUILD_VERSION is not defined, we use a local dev build, that must have been created with make release
install_version="contiv-${BUILD_VERSION:-devbuild}"
pushd cluster
ssh_key=${CONTIV_SSH_KEY:-"$def_key"}
if [ "$ssh_key" == "" ]; then
ssh_key=$(vagrant ssh-config legacy-swarm-master | grep IdentityFile | awk '{print $2}' | xargs)
fi
popd
./scripts/unpack-installer.sh
# Extract and launch the installer
cd release/$install_version
./install/ansible/install_swarm.sh -f ../../cluster/.cfg_legacy-swarm.yaml -e $ssh_key -u $user -i
# Wait for CONTIV to start for up to 10 minutes
sleep 10
for i in {0..20}; do
response=$(curl -k -s -H "Content-Type: application/json" -X POST -d '{"username": "admin", "password": "admin"}' https://$contiv_master:10000/api/v1/auth_proxy/login/ || true)
if [[ $response == *"token"* ]]; then
echo "Install SUCCESS"
echo ""
cat <<EOF
NOTE: Because the Contiv Admin Console is using a self-signed certificate for this demo,
you will see a security warning when the page loads. You can safely dismiss it.
You can access the Contiv master node with:
cd cluster && vagrant ssh legacy-swarm-master
EOF
exit 0
else
echo "$i. Retry login to Contiv"
sleep 30
fi
done
echo "Install FAILED"
exit 1