-
Notifications
You must be signed in to change notification settings - Fork 2
/
nomad-server.bash
54 lines (43 loc) · 1.13 KB
/
nomad-server.bash
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
#!/bin/bash
# In User Data do:
# #!/bin/bash
# export NOMAD_VERSION=0.5.4
# curl https://raw.githubusercontent.com/calebdoxsey/cloud-machine/master/nomad-server.bash | sudo -E /bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
if [ -z "${NOMAD_VERSION}" ] ; then
echo "NOMAD_VERSION is required"
exit 1
fi
echo "[install] installing nomad"
cd /tmp
curl -O -L https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip
unzip nomad_${NOMAD_VERSION}_linux_amd64.zip
mv nomad /usr/bin/nomad
rm nomad_${NOMAD_VERSION}_linux_amd64.zip
mkdir -p /etc/nomad
mkdir -p /var/lib/nomad
cat <<EOF > /etc/nomad/server.hcl
data_dir = "/var/lib/nomad"
server {
enabled = true
bootstrap_expect = 3
}
EOF
cat <<EOF > /etc/systemd/system/nomad.service
[Unit]
Description=Nomad
Documentation=https://nomadproject.io/docs/
[Service]
ExecStart=/usr/bin/nomad agent -config /etc/nomad
ExecReload=/bin/kill -HUP $MAINPID
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
echo "[install] starting nomad"
systemctl daemon-reload
systemctl enable nomad
systemctl start nomad