-
-
Save zwf/c888ec2300e64eb7c3c49d9475ff0504 to your computer and use it in GitHub Desktop.
nomad_server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# server install | |
export IP_ADDRESS=$(hostname -i) | |
echo $IP_ADDRESS | |
apt-get update | |
apt-get install -y unzip dnsmasq wget | |
# install Nomad | |
wget https://releases.hashicorp.com/nomad/0.8.4/nomad_0.8.4_linux_amd64.zip | |
unzip nomad_0.8.4_linux_amd64.zip -d /usr/local/bin/ | |
mkdir -p /var/lhhtttttrffrib/nomad | |
mkdir -p /etc/nomad | |
rm nomad_0.8.4_linux_amd64.zip | |
cat > server.hcl <<EOF | |
addresses { | |
rpc = "ADVERTISE_ADDR" | |
serf = "ADVERTISE_ADDR" | |
} | |
advertise { | |
http = "ADVERTISE_ADDR:4646" | |
rpc = "ADVERTISE_ADDR:4647" | |
serf = "ADVERTISE_ADDR:4648" | |
} | |
bind_addr = "0.0.0.0" | |
data_dir = "/var/lib/nomad" | |
log_level = "DEBUG" | |
server { | |
enabled = true | |
bootstrap_expect = 3 | |
} | |
EOF | |
sed -i "s/ADVERTISE_ADDR/${IP_ADDRESS}/" server.hcl | |
mv server.hcl /etc/nomad/server.hcl | |
cat > nomad.service <<EOF | |
[Unit] | |
Description=Nomad | |
Documentation=https://nomadproject.io/docs/ | |
After=consul.service | |
[Service] | |
ExecStart=/usr/local/bin/nomad agent -config /etc/nomad | |
ExecReload=/bin/kill -HUP $MAINPID | |
LimitNOFILE=65536 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
mv nomad.service /etc/systemd/system/nomad.service | |
systemctl enable nomad | |
systemctl start nomad | |
# install Consul | |
mkdir -p /var/lib/consul | |
wget https://releases.hashicorp.com/consul/1.2.0/consul_1.2.0_linux_amd64.zip | |
unzip consul_1.2.0_linux_amd64.zip -d /usr/local/bin/ | |
rm consul_1.2.0_linux_amd64.zip | |
cat > consul.service <<EOF | |
[Unit] | |
Description=consul | |
Documentation=https://consul.io/docs/ | |
[Service] | |
ExecStart=/usr/local/bin/consul agent \ | |
-advertise=ADVERTISE_ADDR \ | |
-bind=0.0.0.0 \ | |
-bootstrap-expect=3 \ | |
-client=0.0.0.0 \ | |
-data-dir=/var/lib/consul \ | |
-server \ | |
-ui | |
ExecReload=/bin/kill -HUP $MAINPID | |
LimitNOFILE=65536 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
sed -i "s/ADVERTISE_ADDR/${IP_ADDRESS}/" consul.service | |
mv consul.service /etc/systemd/system/consul.service | |
systemctl enable consul | |
systemctl start consul | |
# install fabio | |
wget https://github.com/fabiolb/fabio/releases/download/v1.5.9/fabio-1.5.9-go1.10.2-linux_amd64 | |
mv fabio-1.5.9-go1.10.2-linux_amd64 /usr/local/bin/fabio | |
chmod +x /usr/local/bin/fabio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment