-
Notifications
You must be signed in to change notification settings - Fork 12
/
gce_deploy
executable file
·78 lines (65 loc) · 1.75 KB
/
gce_deploy
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
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
#
# The script to automate testing at google cloud
# If gce account is specified as first parameter,
# The deployment starts automatically
#
# Please make sure you have setup terraform and google cloud account before using the script
#
set -e
gcloud_user="$1"
shift
terraform_args="$@"
hfile="gc.hosts"
touch gc.site_vars.yml
# you can add the following params:
# -var image=debian-9-stretch-v20180611
# -var image=ubuntu-1604-xenial-v20180612
# -var image=ubuntu-1804-bionic-v20180717b
# -var the_count=2
terraform apply -auto-approve $terraform_args
echo '[docker]' > $hfile
ip=""
for h in `terraform output nat_ip | tr , ' '`
do
echo "Waiting for $h on 22 ..."
while ! exec 6<>/dev/tcp/$h/22
do
echo "Waiting for $h on 22 ..."
sleep 10
done
exec 6>&-
ssh-keygen -R $h
ssh-keyscan $h >> ~/.ssh/known_hosts
if [[ -z $ip ]]; then
ip=$h
echo $h >> $hfile
else
echo "$h pool_name=remote1" >> $hfile
fi
done
cat <<EOF >> $hfile
[serviced:children]
docker
[zenoss:children]
serviced
EOF
if [[ -n $gcloud_user ]]; then
./setup gc --user $gcloud_user --become
cat <<EOF
=================================================================================
If you don't have resolving of the zenoss host, you have to add
the line below to hosts file on machine from where you are going to visit zenoss
$ip zenoss5.zenoss.zenoss
Than you can visit https://zenoss5.zenoss.zenoss
=================================================================================
EOF
else
cat <<EOF
======================================================
User is not specified as first parameter
In the order to test run:"
./setup gc --user <your gcloud ssh username> --become
======================================================
EOF
fi