-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
contrib: setup_templates: use write_file for the runner service
This results in the file being written unconditionally on every boot. This also means that the file in cloud-init and the one in the machine will not become out of sync. The drawback is that we need to systemctl deamon-reload on every boot now, which should however be okay performance-wise.
- Loading branch information
Showing
1 changed file
with
23 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,42 +14,28 @@ write_files: | |
ExecStart= | ||
ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM | ||
|
||
runcmd: | ||
- systemctl daemon-reload | ||
- systemctl enable --now --no-block "[email protected]" | ||
- | | ||
set -e -u | ||
|
||
# Set up a service that mounts the job config file system and runs the job | ||
# script inside of it under the `runner` user. | ||
|
||
SERVICE_FILE="github-action-runner.service" | ||
SERVICE_PATH="/etc/systemd/system/${SERVICE_FILE}" | ||
|
||
if ! test -e "${SERVICE_PATH}" | ||
then | ||
cat > "${SERVICE_PATH}" << 'EOF' | ||
[Unit] | ||
Description=GitHub JIT Runner | ||
After=network.target cloud-final.service | ||
|
||
[Service] | ||
ExecStartPre=+/usr/bin/mount -o rw,fmask=0022,dmask=0022,uid=runner,gid=runner --mkdir /dev/disk/by-label/JOBDATA /home/runner/config | ||
ExecStart=/home/runner/config/job.sh | ||
ExecStopPost=+/usr/bin/systemctl poweroff | ||
StandardOutput=journal+console | ||
StandardError=journal+console | ||
User=runner | ||
WorkingDirectory=/home/runner | ||
KillMode=process | ||
KillSignal=SIGTERM | ||
TimeoutStopSec=5min | ||
- path: /etc/systemd/system/github-action-runner.service | ||
content: | | ||
[Unit] | ||
Description=GitHub JIT Runner | ||
After=network.target cloud-final.service | ||
|
||
[Install] | ||
WantedBy=cloud-init.target | ||
EOF | ||
[Service] | ||
ExecStartPre=+/usr/bin/mount -o rw,fmask=0022,dmask=0022,uid=runner,gid=runner --mkdir /dev/disk/by-label/JOBDATA /home/runner/config | ||
ExecStart=/home/runner/config/job.sh | ||
ExecStopPost=+/usr/bin/systemctl poweroff | ||
StandardOutput=journal+console | ||
StandardError=journal+console | ||
User=runner | ||
WorkingDirectory=/home/runner | ||
KillMode=process | ||
KillSignal=SIGTERM | ||
TimeoutStopSec=5min | ||
|
||
[Install] | ||
WantedBy=cloud-init.target | ||
|
||
systemctl daemon-reload | ||
systemctl enable "${SERVICE_FILE}" | ||
systemctl start --no-block "${SERVICE_FILE}" | ||
fi | ||
runcmd: | ||
- systemctl daemon-reload | ||
- systemctl enable --now --no-block [email protected] | ||
- systemctl enable --now --no-block github-action-runner.service |