Compare commits

...

5 Commits

Author SHA1 Message Date
Starbeamrainbowlabs e0f5321932
nomad: add initial jobspec
continuous-integration/laminar-eldarion Build failed with exit code 123 after 2 seconds Details
2022-05-01 02:29:49 +01:00
Starbeamrainbowlabs 61463167dd
add cgroups memory task
This is important if we want Nomad to regulate and limit the amount of 
memory that jobs use.
2022-05-01 02:29:41 +01:00
Starbeamrainbowlabs 0514c6fb67
consul: bugfix 2022-05-01 02:27:32 +01:00
Starbeamrainbowlabs 3025fda8e4
remove test job 2022-05-01 02:27:21 +01:00
Starbeamrainbowlabs 30700caf1c
jobs/dns: move old job file around
we don't need it right now, but we should keep it around as it's not 
certain that we'll never need it again
2022-05-01 02:27:14 +01:00
7 changed files with 77 additions and 9 deletions

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
RUN "uptime";
COPY "${JOBFILE_DIR}/testfile.txt" "/tmp";
RUN "rm /tmp/testfile.txt";

View File

@ -1 +0,0 @@
it works!

18
src/steps-config/80-nomad.sh Executable file
View File

@ -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

View File

@ -12,7 +12,7 @@ subtask_end "$?";
# No UFW rules required, as we're now using wesher/wireguard, and allowing all inbound traffic on that interface
subtask_begin "Starting Consul and enabling on boot";
systemctl consul;
systemctl enable --now consul;
subtask_end "$?";
task_end "$?";

View File

@ -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 "$?";

View File

@ -0,0 +1,39 @@
#!/usr/bin/env bash
check_cgroups_memory() {
task_begin "Checking memory cgroups";
cgroups_enabled="$(awk '/memory/ { print $2 }' < /proc/cgroups)";
if [[ "${cgroups_enabled}" -ne 0 ]]; then
echo ">>> memory cgroups already enabled";
return 0;
fi
filepath_cmdline="/boot/cmdline.txt";
if [[ ! -e "${filepath_cmdline}" ]]; then
filepath_cmdline="/boot/firmware/cmdline.txt";
fi
if [[ ! -e "${filepath_cmdline}" ]]; then
echo ">>> Failed to find cmdline.txt; can't check for cgroups";
return 1;
fi
if grep -q cgroup_enable=memory /boot/cmdline.txt; then
echo ">>> memory cgroups already present in cmdline.txt, a reboot is required to apply the update";
return 0;
fi
echo ">>> memory cgroups not present in cmdline.txt, enabling....";
(tr -d '\n' <"${filepath_cmdline}" && echo " cgroup_enable=memory cgroup_memory=1") | sudo tee "${filepath_cmdline}.new";
sudo mv "${filepath_cmdline}" "${filepath_cmdline}.old-$(date +"%Y-%m-%d")";
sudo mv "${filepath_cmdline}.new" "${filepath_cmdline}";
echo ">>> New contents of cmdline.txt:";
cat "${filepath_cmdline}";
echo ">>> A reboot is required to apply the changes.";
task_end "$?" "Failed to check memory cgroups"
}