From e0f5321932d259c09f9b053d35d490cb875a4d90 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 1 May 2022 02:29:49 +0100 Subject: [PATCH] nomad: add initial jobspec --- src/steps-config/80-nomad.sh | 18 ++++++++++++++++++ src/steps-postinstall/80-nomad.sh | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 src/steps-config/80-nomad.sh create mode 100755 src/steps-postinstall/80-nomad.sh diff --git a/src/steps-config/80-nomad.sh b/src/steps-config/80-nomad.sh new file mode 100755 index 0000000..b3fd023 --- /dev/null +++ b/src/steps-config/80-nomad.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +nomad_mode="$(ask_multichoice "Nomad installation mode" "none" "client" "server" "both")"; + +if [[ "${nomad_mode}" != "none" ]]; then + queue_apt_install "hashicorp-nomad"; + case "${nomad_mode}" in + client ) + queue_apt_install "hashicorp-nomad-systemd-client"; + ;; + server ) + queue_apt_install "hashicorp-nomad-systemd-server"; + ;; + both ) + queue_apt_install "hashicorp-nomad-systemd-both"; + ;; + esac +fi diff --git a/src/steps-postinstall/80-nomad.sh b/src/steps-postinstall/80-nomad.sh new file mode 100755 index 0000000..16a797c --- /dev/null +++ b/src/steps-postinstall/80-nomad.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + + +task_begin "Installing Nomad configuration"; +# /etc/nomad is created by the apt postinstall script + +subtask_begin "Copying configuration files"; +cp "configs/nomad-client.hcl" "/etc/nomad/client.hcl"; +cp "configs/nomad-server.hcl" "/etc/nomad/server.hcl"; +cp "configs/nomad-both.hcl" "/etc/nomad/both.hcl"; +subtask_end "$?"; + +# No UFW rules required, as we're now using wesher/wireguard, and allowing all inbound traffic on that interface + +subtask_begin "Starting Nomad and enabling on boot"; +systemctl enable --now nomad; +subtask_end "$?"; + +task_end "$?";