Move the Forgejo Actions runner to its own machine #5
Loading…
Reference in a new issue
No description provided.
Delete branch "armin-bot/openneo-code:claude/separate-runner-box"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CI on the shared box has been starving itself: in a recent deploy run,
actions/cachetimed out talking to the runner's own cache proxy (getCacheEntry failed: Request timeout), so Install gems recompiled every native gem from scratch (7 minutes). On one vCPU and 2GB, Forgejo plus a CI job pushes the machine into swap, and the cache proxy can't answer in time.This moves the runner to its own machine, a shared Linode 2GB:
runner.openneo.net. CI can no longer slow Forgejo down (or vice versa). Jobs, which run in Docker as a root-equivalent user, also no longer share a machine with Forgejo's repos and secrets.The impress side is OpenNeo/impress#33, which lets
deploy-bot's key work from the new box's IP.Changes
inventory.cfgsplits into two groups:forgejo(code.openneo.net) andrunner(runner.openneo.net).setup-machine.ymlandsetup-security.ymlapply to both machines, and the hostname now comes from the inventory. The swap file moves here fromsetup-actions.yml, so both machines get one. The Forgejo box already has it, so nothing changes there.setup-actions.ymltargetsrunner. Registration runs Forgejo's own CLI, so that one task usesdelegate_toto run on the Forgejo box. The runner's name comes from its host:runner-openneo-net.capacity: 1and the 1GB container caps still fit a 2GB box.remove-colocated-runner.yml(new, one-off) removes the old runner from the Forgejo box: the service, binary,runneruser (and its cache data), Docker and its data, the weekly prune cron and the port-4000 ufw rule. It can be deleted from the repo once it has run.setup-security.ymlnow reloads sshd when its settings change (before, they waited for a reboot). It also checks sshd's effective config, because an override insshd_config.d/would win.Reusing the runner's identity
The new box registers with the same
runner_secret. I checkedRegisterRunnerin Forgejo v17.0'smodels/actions/forgejo.go: the first 16 characters of the secret pick the runner's UUID, and re-registering an existing UUID updates its name, scope and labels in place. So the new box takes over the existing runner (renamedrunner-openneo-net), and there's nothing to deregister. Both daemons can run at once during the move. Each just takes jobs as the same runner.Rollout
Order matters, so that deploys never run from a machine
deploy-botdoesn't accept, and the old runner never gets cut off mid-deploy:74.207.234.34) with its Cloud Firewall: inbound Drop, except TCP 22; outbound Accept.runner.openneo.netat it (A74.207.234.34, AAAA2600:3c02::2000:ecff:fe40:eada).rooton the new box). Use the same sudo password as on code.openneo.net, because onesetup-actions.ymlrun usessudoon both machines. (A check before registration catches a mismatch.)bin/deploy:setupfrom OpenNeo/impress#33's branch, then merge it.deploy-botnow accepts both machines.runner-openneo-net. This also checks that sshd really has root and password login off: a fresh Linode can override them in/etc/ssh/sshd_config.d/.sudo systemctl start forgejo-runnerbrings the old runner back./var/lib/dockerfails with "Device or resource busy", reboot first, then re-run the playbook.)45.79.220.14fromdeploy_bot_allowed_ips, and runbin/deploy:setupagain.Testing
ansible-playbook --syntax-checkpasses forsetup-all.yml,remove-colocated-runner.yml, and impress'sdeploy/setup.yml.--list-hostsconfirms that machine/security target both boxes, Forgejo only code.openneo.net, and the runner only runner.openneo.net.delegate_tounder--limit runnerwith a local two-host test: the delegated task runs on the Forgejo box even though it's outside the limit, andbecome_user,environment,chdirandstdinapply there. It also confirmed that two daemons sharing one runner identity is safe (each task is handed out once), and that the ufw delete matches the original commented rule. Its rollout catches are fixed: steps 6–7, the sudo check, and the sshd reload and effective-config check.🤖 Generated with Claude Code
https://claude.ai/code/session_014PWWd1c4UFRKce9t7XXiaP