-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision-app.sh
49 lines (42 loc) · 1023 Bytes
/
provision-app.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
#!/bin/bash
sudo apt-get install -y unzip
cd /tmp
wget https://releases.hashicorp.com/serf/0.7.0/serf_0.7.0_linux_amd64.zip
unzip serf_0.7.0_linux_amd64.zip
sudo chmod +x serf
sudo mv serf /usr/local/bin
sudo apt-get install -y nginx
cd /tmp
cat <<EOF >serf-agent.conf
description "Serf agent"
start on runlevel [2345]
stop on runlevel [!2345]
exec /usr/local/bin/serf agent -bind=192.168.33.12 -node=app01 -tag role=app >> /var/log/serf.log 2>&1
EOF
sudo mv serf-agent.conf /etc/init/serf-agent.conf
sudo start serf-agent
cat <<EOF >serf-join.conf
description "Join the serf cluster"
start on runlevel [2345]
stop on runlevel [!2345]
task
respawn
script
sleep 5
exec /usr/local/bin/serf join 192.168.33.10
end script
EOF
sudo mv serf-join.conf /etc/init/serf-join.conf
sudo start serf-join
cat <<EOF >index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body>
<h1>Hello from app node</h1>
</body>
</html>
EOF
sudo mv index.html /usr/share/nginx/html/index.html