-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap.sh
executable file
·34 lines (28 loc) · 1008 Bytes
/
bootstrap.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
#!/bin/bash
set -x
. environments
if [ -z "$NUM_OF_DROPLETS" ]; then
NUM_OF_DROPLETS=2
fi
NAME_PREFIX=tcore0
for i in `seq $NUM_OF_DROPLETS`; do ./create_droplet.sh $NAME_PREFIX$i; done
# update host list for fabric use
:> allhosts
for i in `seq $NUM_OF_DROPLETS`; do
DROPLET_STATUS="new"
DROPLET_DETAILS=""
while [ "$DROPLET_STATUS" != "active" ]; do
sleep 15
DROPLET_DETAILS=`./get_droplet.sh | jq '.droplets[] | select(.name == '\""$NAME_PREFIX$i"\"')'`
DROPLET_STATUS=`echo $DROPLET_DETAILS | jq '.status' | sed 's/"//g'`
done
PUBLIC_IP=`echo $DROPLET_DETAILS | jq '.networks.v4 | .[] | select(.type =="public") | .ip_address' | sed 's/"//g'`
echo $PUBLIC_IP >>allhosts;
done
# cleanup known hosts lists
:> ~/.fleetctl/known_hosts
for h in `cat allhosts`; do ssh-keygen -f "$HOME/.ssh/known_hosts" -R $h; done
# wait some time to make sure Droplets internally ready
sleep 120
fab set_hosts deploy_minion
fab -H `head -1 allhosts` deploy_master