delete old nomad job files
Some checks are pending
continuous-integration/laminar-eldarion Build failed with exit code 123 after 3 seconds

This commit is contained in:
Starbeamrainbowlabs 2022-05-15 01:24:37 +01:00
parent e0f5321932
commit 3a859cfc6f
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 0 additions and 106 deletions

View file

@ -1,63 +0,0 @@
#!/usr/bin/env bash
log_msg() {
echo -e "[ ${HOSTNAME} ] [ $(date -u +"%Y-%m-%dT%H:%M:%SZ") ] $*" >&2;
}
log_msg "Installing nomad";
sudo apt-get update;
sudo apt-get install --yes hashicorp-nomad;
log_msg "nomad installed successfully. Version:";
nomad --version;
log_msg "Creating directories";
if [[ ! -d "/etc/nomad" ]]; then
sudo mkdir /etc/nomad;
sudo chown root:root /etc/nomad;
fi
if [[ ! -d "/srv/nomad" ]]; then
sudo mkdir /srv/nomad;
sudo chown root:root /srv/nomad;
sudo chmod 0750 /srv/nomad;
fi
check_cgroups_memory() {
log_msg "Checking memory cgroups";
cgroups_enabled="$(awk '/memory/ { print $2 }' < /proc/cgroups)";
if [[ "${cgroups_enabled}" -ne 0 ]]; then
log_msg "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
log_msg "Failed to find cmdline.txt; can't check for cgroups";
return 1;
fi
if grep -q cgroup_enable=memory /boot/cmdline.txt; then
log_msg "memory cgroups already present in cmdline.txt, a reboot is required to apply the update";
return 0;
fi
log_msg "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}";
log_msg "New contents of cmdline.txt:";
cat "${filepath_cmdline}";
log_msg "A reboot is required to apply the changes.";
}
check_cgroups_memory;

View file

@ -1,22 +0,0 @@
#!/usr/bin/env bash
SCRIPT "${JOBFILE_DIR}/common.sh";
COPY "../nomad/both.hcl" "/tmp/both.hcl"
RUN "sudo mv /tmp/both.hcl /etc/nomad/both.hcl";
RUN "sudo chown root:root /etc/nomad/both.hcl";
RUN "sudo apt-get install --yes hashicorp-nomad-systemd-both";
# Commented out since we're now running over wgoverlay & allowing all traffic on that interface because dynamic ports
# RUN "sudo ufw allow 4646/tcp comment nomad-http";
# RUN "sudo ufw allow 4647/tcp comment nomad-rpc";
# RUN "sudo ufw allow 4648/tcp comment nomad-serf";
RUN "sudo ufw delete allow 4646/tcp comment nomad-http";
RUN "sudo ufw delete allow 4647/tcp comment nomad-rpc";
RUN "sudo ufw delete allow 4648/tcp comment nomad-serf";
RUN "sudo systemctl enable nomad.service";
RUN "sudo systemctl restart nomad.service";

View file

@ -1,21 +0,0 @@
#!/usr/bin/env bash
SCRIPT "jobs/nomad-both/common.sh";
COPY "../nomad/client.hcl" "/tmp/client.hcl"
RUN "sudo mv /tmp/client.hcl /etc/nomad/client.hcl";
RUN "sudo chown root:root /etc/nomad/client.hcl";
RUN "sudo apt-get install --yes hashicorp-nomad-systemd-client";
# Commented out since we're now running over wgoverlay & allowing all traffic on that interface because dynamic ports
# RUN "sudo ufw allow 4646/tcp comment nomad-http";
# RUN "sudo ufw allow 4647/tcp comment nomad-rpc";
# RUN "sudo ufw allow 4648/tcp comment nomad-serf";
RUN "sudo ufw delete allow 4646/tcp comment nomad-http";
RUN "sudo ufw delete allow 4647/tcp comment nomad-rpc";
RUN "sudo ufw delete allow 4648/tcp comment nomad-serf";
RUN "sudo systemctl enable nomad.service";
RUN "sudo systemctl restart nomad.service";