Merge pull request 'Ask for the registration and capacity at first boot' (#1) from first-boot-setup into main
os / os (push) Successful in 4m6s
os / os (push) Successful in 4m6s
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
commit
6ebddf18ce
7 files changed
+59
-9
No files matched your search
@@ -23,14 +23,12 @@ image.
|
||||
Download [the disk image](https://git.plabble.org/api/packages/Job79/generic/runneros/latest/runneros.qcow2),
|
||||
resize it to the disk size you want and boot it with UEFI and a TPM. At first
|
||||
boot, the screen offers a recovery key for the encrypted disk and asks for a
|
||||
root password. Then log in as root and register the runner with a token from
|
||||
Gitea's runner settings:
|
||||
root password. Then it asks how many jobs to run at once, the Gitea URL and a
|
||||
registration token from Gitea's runner settings. It registers under the
|
||||
hostname, `runneros-` and four hex digits, and starts.
|
||||
|
||||
```sh
|
||||
gitea-runner -c /etc/gitea-runner/config.yaml register
|
||||
```
|
||||
|
||||
It registers under the hostname, `runneros-` and four hex digits, and starts.
|
||||
To change the number of parallel jobs later, run `systemctl edit
|
||||
gitea-runner` and set `Environment=CAPACITY=<jobs>` under `[Service]`.
|
||||
|
||||
To start over, run `systemctl start factory-reset.target` as root. It reboots
|
||||
and wipes the root partition (`/etc` and `/var`), and the VM sets itself up as
|
||||
|
||||
@@ -8,6 +8,8 @@ runner:
|
||||
# file is where `gitea-runner register` keeps the registration, wherever it
|
||||
# runs. gitea-runner.path starts the runner once it is there.
|
||||
file: /var/lib/gitea-runner/.runner
|
||||
# capacity is the number of parallel jobs, set by gitea-runner.service.
|
||||
capacity: ${CAPACITY}
|
||||
# shutdown_timeout lets running jobs finish when the runner stops, as it
|
||||
# does before an update reboots the machine.
|
||||
shutdown_timeout: 1h
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
# systemd-networkd is disabled by Fedora, which uses NetworkManager.
|
||||
enable systemd-networkd.service
|
||||
|
||||
# gitea-runner.path starts the runner once it is registered.
|
||||
# gitea-runner-setup.service registers the runner, and gitea-runner.path then
|
||||
# starts it.
|
||||
enable gitea-runner-setup.service
|
||||
enable gitea-runner.path
|
||||
disable gitea-runner.service
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# gitea-runner-setup.service runs /usr/libexec/gitea-runner-setup on the
|
||||
# console until the runner is registered, after systemd-firstboot has asked
|
||||
# its questions there. Logins wait for it, as for systemd-firstboot, so no
|
||||
# getty reads the same console.
|
||||
[Unit]
|
||||
Description=Gitea runner setup
|
||||
ConditionPathExists=!/var/lib/gitea-runner/.runner
|
||||
Wants=network-online.target
|
||||
After=systemd-firstboot.service network-online.target
|
||||
Before=systemd-user-sessions.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
# HOME is where gitea-runner keeps its cache, as in gitea-runner.service.
|
||||
Environment=HOME=/var/lib/gitea-runner
|
||||
ExecStart=/usr/libexec/gitea-runner-setup
|
||||
StandardInput=tty
|
||||
StandardOutput=tty
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -1,5 +1,5 @@
|
||||
# gitea-runner.path starts the runner once it is registered, so a new machine
|
||||
# waits for `gitea-runner -c /etc/gitea-runner/config.yaml register`.
|
||||
# waits for gitea-runner-setup.service.
|
||||
[Unit]
|
||||
Description=Start the Gitea runner once registered
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ After=network-online.target podman.socket
|
||||
Requires=podman.socket
|
||||
|
||||
[Service]
|
||||
# CAPACITY is the number of parallel jobs. gitea-runner-setup writes a drop-in
|
||||
# that overrides it, which `systemctl edit gitea-runner` changes.
|
||||
Environment=CAPACITY=1
|
||||
# HOME holds the cache of actions/cache, next to the registration.
|
||||
Environment=HOME=/var/lib/gitea-runner
|
||||
Environment=DOCKER_HOST=unix:///run/podman/podman.sock
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# gitea-runner-setup asks on the console for the number of parallel jobs and
|
||||
# the runner's registration, and registers the runner. gitea-runner.path then
|
||||
# starts it. gitea-runner-setup.service runs it until the runner is registered.
|
||||
#
|
||||
# The capacity goes to a drop-in of gitea-runner.service, which passes it to
|
||||
# /etc/gitea-runner/config.yaml as CAPACITY. It is written first, because the
|
||||
# runner starts as soon as it is registered.
|
||||
set -euo pipefail
|
||||
|
||||
read -rp "Parallel jobs [1]: " capacity
|
||||
[[ $capacity =~ ^[1-9][0-9]*$ ]] || capacity=1
|
||||
mkdir -p /etc/systemd/system/gitea-runner.service.d
|
||||
printf '[Service]\nEnvironment=CAPACITY=%s\n' "$capacity" \
|
||||
> /etc/systemd/system/gitea-runner.service.d/capacity.conf
|
||||
systemctl daemon-reload
|
||||
|
||||
export CAPACITY=$capacity
|
||||
until [[ -f /var/lib/gitea-runner/.runner ]]; do
|
||||
read -rp "Gitea URL: " url
|
||||
read -rp "Registration token: " token
|
||||
gitea-runner -c /etc/gitea-runner/config.yaml register --no-interactive \
|
||||
--instance "$url" --token "$token" || echo "Try again."
|
||||
done
|
||||
Reference in new issue
Block a user