vbem / multi-runners

Multi self-hosted runners on single host!
Apache License 2.0
118 stars 10 forks source link

Start the runners as root #4

Closed guidodobboletta closed 7 months ago

guidodobboletta commented 7 months ago

I'm trying to use this wrapper script but the issue I'm having is that containers in github actions run as root so if you try to use this in combination with a workflow that requires containers then you'll get a permission error. I wanted to run this wrapper as root but there's a hardcoded useradd which obviously conflicts with the existing root user.

vbem commented 7 months ago

Hi,

It's hard to maintain multi self-hosted runners under a same Linux user (such as root), because:

  1. This wrapper app use user-level systemd service to manage multi self-hosted runners on a single Linux host.
  2. We need to isolate different runner environments as much as possible.

The sudo useradd command in this wrapper actually create one Linux local user for one self-hosted runner on the VM, as well as set the new user in both runners and docker groups, where runners group can run sudo without password on the VM, and docker group enables the Docker CLI permissions. That is, the runner users can execute both sudo blablabla and docker blablabla by default. If any runner was already created on the VM, you can type sudo su - <runner-user-name> and then check those permissions.

Meanwhile, this script does not need to be executed by root, but by a Linux user with no-password sudo permission, since all root permission required operations were all decorated with sudo with in this script.

For your needs - <Start the runners as root single user>, you can try these solutions:

  1. Directly add multi self-hosted runners under root on your VM, referring to official method.
  2. Recommended: Modify the commands in your workflow files, decorate them with sudo if root permission is required. This is also compatible with executing as root.

Hope these information works for you. 😄