forked from contiv/install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswarm_mode_test.sh
67 lines (59 loc) · 2.12 KB
/
swarm_mode_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
57
58
59
60
61
62
63
64
65
66
67
#!/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_swarm-mode.yaml | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}" | head -n 1 | 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"}
pushd cluster
ssh_key=${CONTIV_SSH_KEY:-"$def_key"}
if [ "$ssh_key" == "" ]; then
ssh_key=$(vagrant ssh-config swarm-mode-master | grep IdentityFile | awk '{print $2}' | xargs)
fi
popd
# Extract and launch the installer
mkdir -p release
cd release
# If BUILD_VERSION is not defined, we use a local dev build, that must have been created with make release
release_name="contiv-${BUILD_VERSION:-devbuild}"
release_tarball="${release_name}.tgz"
release_local_tarball="contiv-full-${BUILD_VERSION}.tgz"
if [ -f "${release_local_tarball}" ]; then
tar oxf "${release_local_tarball}"
else
if [ ! -f "${release_tarball}" ]; then
# For release builds, get the build from github releases
curl -L -O https://github.com/contiv/install/releases/download/${BUILD_VERSION}/${release_name}.tgz
fi
tar oxf "${release_name}.tgz"
fi
cd $release_name
./install/ansible/install_swarm.sh -f ../../cluster/.cfg_swarm-mode.yaml -e $ssh_key -u $user -p
# 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 swarm-mode-master
EOF
exit 0
else
echo "$i. Retry login to Contiv"
sleep 30
fi
done
echo "Install FAILED"
exit 1