Created
September 22, 2021 02:21
-
-
Save graphaelli/052e40a60b72df79494c1f5e6e8d3b73 to your computer and use it in GitHub Desktop.
nomad on Ubuntu 21.10
This file contains hidden or 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.boot_timeout = 600 | |
config.vm.box = "ubuntu/impish64" | |
config.vm.network "public_network", bridge: "en0: Wi-Fi (Wireless)", use_dhcp_assigned_default_route: true | |
config.vm.network "forwarded_port", guest: 4646, host: 4646, auto_correct: true, host_ip: "127.0.0.1" | |
config.vm.synced_folder ".", "/vagrant", disabled: false | |
# vagrant plugin install vagrant-disksize | |
config.disksize.size = '50GB' | |
config.vm.provision "shell", inline: <<-SHELL | |
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list | |
sudo apt autoremove -y | |
sudo apt update | |
sudo apt-get source linux-source | |
sudo apt install -y virtualbox-guest-utils | |
# until docker-ce is available | |
echo "Installing docker..." | |
sudo apt install -y docker.io | |
sudo usermod -aG docker ${USER} | |
# install go | |
echo "Installing go..." | |
curl -Ls https://dl.google.com/go/go1.17.1.linux-amd64.tar.gz | sudo tar -C /usr/local -xzf - | |
sudo apt install -y curl unzip vim | |
echo "Installing Consul..." | |
CONSUL_VERSION=1.10.2 | |
curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip -o consul.zip | |
unzip consul.zip | |
sudo install consul /usr/bin/consul | |
( | |
cat <<-EOF | |
[Unit] | |
Description=consul agent | |
Requires=network-online.target | |
After=network-online.target | |
[Service] | |
Restart=on-failure | |
ExecStart=/usr/bin/consul agent -dev | |
ExecReload=/bin/kill -HUP $MAINPID | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
) | sudo tee /etc/systemd/system/consul.service | |
sudo systemctl enable consul.service | |
sudo systemctl start consul | |
echo "Installing Nomad..." | |
NOMAD_VERSION=1.1.5 | |
cd /tmp/ | |
curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip | |
unzip nomad.zip | |
sudo install nomad /usr/bin/nomad | |
sudo mkdir -p /etc/nomad.d /var/lib/nomad | |
sudo chmod a+w /etc/nomad.d | |
( | |
cat <<-EOF | |
client { | |
enabled = true | |
} | |
EOF | |
) | sudo tee /etc/nomad.d/client.hcl | |
( | |
cat <<-EOF | |
data_dir = /var/lib/nomad | |
server { | |
enabled = true | |
bootstrap_expect = 1 | |
} | |
EOF | |
) | sudo tee /etc/nomad.d/server.hcl | |
( | |
cat <<-EOF | |
[Unit] | |
Description=Nomad | |
Documentation=https://www.nomadproject.io/docs/ | |
Wants=network-online.target | |
After=network-online.target | |
# When using Nomad with Consul it is not necessary to start Consul first. These | |
# lines start Consul before Nomad as an optimization to avoid Nomad logging | |
# that Consul is unavailable at startup. | |
Wants=consul.service | |
After=consul.service | |
[Service] | |
ExecReload=/bin/kill -HUP $MAINPID | |
ExecStart=/usr/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 | |
EOF | |
) | sudo tee /etc/systemd/system/nomad.service | |
sudo systemctl enable nomad.service | |
sudo systemctl start nomad | |
for bin in cfssl cfssl-certinfo cfssljson | |
do | |
echo "Installing $bin..." | |
curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin} | |
sudo install /tmp/${bin} /usr/local/bin/${bin} | |
done | |
nomad -autocomplete-install | |
echo "Provisioning complete" | |
SHELL | |
config.vm.provider "virtualbox" do |v| | |
v.customize ["modifyvm", :id, "--nictype1", "virtio"] | |
v.memory = 3172 | |
v.cpus = 2 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment