Roadmap 1.2: Install and register act_runner on the runner VM #18

Open
opened 2026-12-03 04:39:32 +01:00 by claude-bot · 0 comments

Why

The runner VM (kasun/homelab-infrastructure-as-code#82) needs a reproducible, hardened runner setup. Afterwards the old Docker runner can be retired.

Enterprise practice: configuration management for build agents, short-lived registration secrets, least privilege for the agent.

Depends on kasun/homelab-infrastructure-as-code#82.

Design

act_runner runs as a systemd service on a dedicated VM; jobs run in Docker containers, one fresh container per job. The design decision is recorded in kasun/homelab-infrastructure-as-code#82.

Steps

  • Dedicated SSH key for the runner VM on the Ansible node (~/.ssh/runner_vm, created before the VM, public key in runnerAnsibleSshPublicKey of 01-proxmox-infra). The inventory uses it only for the runner host, never the general deploy key. Access to the runner VM is as sensitive as the CI credentials
  • Base setup: install qemu-guest-agent (the VM has the agent enabled in Proxmox, the cloud image doesn't ship it), unattended security updates
  • Role docker: install Docker Engine from Docker's apt repo, pinned version
  • Role gitea_runner: dedicated user act_runner without sudo, in the docker group (note: that is root-equivalent on the VM; the VM boundary is the real isolation)
  • Download a pinned act_runner binary and verify its SHA-256
  • Template config.yaml, 0600, owned by act_runner:
    • runner.capacity: 1
    • a unique label mapped to a pinned job image, e.g. runner-vm:docker://<image>@sha256:...
    • container.docker_host: "-" so job containers don't get the Docker socket (check the current act_runner docs for the exact semantics)
    • no privileged, no extra valid_volumes
  • systemd unit with hardening that still lets the runner reach Docker: NoNewPrivileges=yes, ProtectSystem=strict, ProtectHome=yes, PrivateTmp=yes, ReadWritePaths= limited to the runner's dirs
  • Registration: the playbook asks for the token with vars_prompt (private: true, no_log: true) and only registers when .runner doesn't exist. The token is not stored anywhere (no .env, no OpenBao): generate a fresh one in Gitea when needed and reset it right after registering
  • Register at user level (kasun) so both homelab-* repos can use it, not instance-wide
  • Prune old job images and volumes regularly (systemd timer with docker system prune --filter until=...)
  • Switch the workflows' runs-on to the new label and run each one once on the new runner
  • Retire the old runner: deregister it in Gitea, remove the gitea-runner service and GITEA_RUNNER_REGISTRATION_TOKEN from the Docker host's compose file and .env, delete /home/pi/docker/gitea-runner/ (its .runner file is a working credential), then reset the registration token

Tools

Ansible, act_runner, Docker, systemd hardening.

Done when

  • A test workflow with runs-on: <new label> succeeds on the new runner
  • A test job can't see the Docker socket (ls /var/run/docker.sock fails inside the job)
  • The Docker runner is gone and its token is deregistered
  • The runner host in the inventory uses ~/.ssh/runner_vm, and that key works on no other host

Portfolio evidence

  • systemd-analyze security act_runner output
  • Screenshot of the runner in Gitea and a successful job

Part of the security roadmap. Keep the evidence below for the write-up (README / blog post).

## Why The runner VM (kasun/homelab-infrastructure-as-code#82) needs a reproducible, hardened runner setup. Afterwards the old Docker runner can be retired. **Enterprise practice:** configuration management for build agents, short-lived registration secrets, least privilege for the agent. Depends on kasun/homelab-infrastructure-as-code#82. ## Design act_runner runs as a systemd service on a dedicated VM; jobs run in Docker containers, one fresh container per job. The design decision is recorded in kasun/homelab-infrastructure-as-code#82. ## Steps - [ ] Dedicated SSH key for the runner VM on the Ansible node (`~/.ssh/runner_vm`, created before the VM, public key in `runnerAnsibleSshPublicKey` of `01-proxmox-infra`). The inventory uses it only for the runner host, never the general deploy key. Access to the runner VM is as sensitive as the CI credentials - [ ] Base setup: install `qemu-guest-agent` (the VM has the agent enabled in Proxmox, the cloud image doesn't ship it), unattended security updates - [ ] Role `docker`: install Docker Engine from Docker's apt repo, pinned version - [ ] Role `gitea_runner`: dedicated user `act_runner` without sudo, in the `docker` group (note: that is root-equivalent on the VM; the VM boundary is the real isolation) - [ ] Download a pinned `act_runner` binary and verify its SHA-256 - [ ] Template `config.yaml`, `0600`, owned by `act_runner`: - `runner.capacity: 1` - a unique label mapped to a pinned job image, e.g. `runner-vm:docker://<image>@sha256:...` - `container.docker_host: "-"` so job containers **don't** get the Docker socket (check the current act_runner docs for the exact semantics) - no `privileged`, no extra `valid_volumes` - [ ] systemd unit with hardening that still lets the runner reach Docker: `NoNewPrivileges=yes`, `ProtectSystem=strict`, `ProtectHome=yes`, `PrivateTmp=yes`, `ReadWritePaths=` limited to the runner's dirs - [ ] Registration: the playbook asks for the token with `vars_prompt` (`private: true`, `no_log: true`) and only registers when `.runner` doesn't exist. The token is **not stored** anywhere (no `.env`, no OpenBao): generate a fresh one in Gitea when needed and reset it right after registering - [ ] Register at user level (`kasun`) so both `homelab-*` repos can use it, not instance-wide - [ ] Prune old job images and volumes regularly (systemd timer with `docker system prune --filter until=...`) - [ ] Switch the workflows' `runs-on` to the new label and run each one once on the new runner - [ ] Retire the old runner: deregister it in Gitea, remove the `gitea-runner` service and `GITEA_RUNNER_REGISTRATION_TOKEN` from the Docker host's compose file and `.env`, delete `/home/pi/docker/gitea-runner/` (its `.runner` file is a working credential), then reset the registration token ## Tools Ansible, act_runner, Docker, systemd hardening. ## Done when - A test workflow with `runs-on: <new label>` succeeds on the new runner - A test job can't see the Docker socket (`ls /var/run/docker.sock` fails inside the job) - The Docker runner is gone and its token is deregistered - The runner host in the inventory uses `~/.ssh/runner_vm`, and that key works on no other host ## Portfolio evidence - [ ] `systemd-analyze security act_runner` output - [ ] Screenshot of the runner in Gitea and a successful job --- _Part of the security roadmap. Keep the evidence below for the write-up (README / blog post)._
claude-bot Bot added this to the Security Roadmap 1: Secure container supply chain milestone 2026-12-03 04:39:32 +01:00
claude-bot Bot added the security-roadmap label 2026-12-03 04:39:32 +01:00
claude-bot Bot added this to the Security Roadmap project 2026-12-03 04:39:38 +01:00
claude-bot Bot changed title from Roadmap 1.2: Install and register act_runner on the runner LXC to Roadmap 1.2: Install and register act_runner on the runner VM 2026-12-04 18:25:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kasun/homelab-ansible#18