Skip to content

Instantly share code, notes, and snippets.

@jonaskahn
Last active December 5, 2022 09:02
Show Gist options
  • Save jonaskahn/e035e11357686237ab18c982acafd7d7 to your computer and use it in GitHub Desktop.
Save jonaskahn/e035e11357686237ab18c982acafd7d7 to your computer and use it in GitHub Desktop.
#! /bin/bash
sudo apt install -y unzip zip
export NOMAD_VERSION=1.4.3
printf "Download & install nomad v${NOMAD_VERSION}\n"
curl --silent --remote-name https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip
unzip nomad_${NOMAD_VERSION}_linux_amd64.zip
sudo chown root:root nomad
sudo mv nomad /usr/local/bin/
nomad version
nomad -autocomplete-install
complete -C /usr/local/bin/nomad nomad
sudo mkdir --parents /opt/nomad
sudo useradd --system --home /etc/nomad.d --shell /bin/false nomad
sudo rm -rf /etc/systemd/system/nomad.service
echo "
[Unit]
Description=Nomad
Documentation=https://www.nomadproject.io/docs/
Wants=network-online.target
After=network-online.target
Wants=consul.service
After=consul.service
[Service]
User=nomad
Group=nomad
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/nomad agent -config /etc/nomad.d
KillMode=process
KillSignal=SIGINT
LimitNOFILE=65536
LimitNPROC=infinity
Restart=on-failure
RestartSec=2
TasksMax=infinity
OOMScoreAdjust=-1000
[Install]
WantedBy=multi-user.target
" | sudo tee -a /etc/systemd/system/nomad.service
sudo rm -rf nomad_${NOMAD_VERSION}_linux_amd64.zip
sudo mkdir --parents /etc/nomad.d
sudo chmod 700 /etc/nomad.d
sudo touch /etc/nomad.d/nomad.hcl && \
sudo touch /etc/nomad.d/server.hcl && \
sudo touch /etc/nomad.d/client.hcl && \
sudo touch /etc/nomad.d/consul.hcl
sudo systemctl enable nomad
sudo chown --recursive nomad:nomad /etc/nomad.d
sudo chown --recursive nomad:nomad /opt/nomad
sudo usermod -aG docker nomad
@jonaskahn
Copy link
Author

jonaskahn commented Nov 8, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment