0

We assemble android application using GH Actions on self-hosted agents. Right now we upgraded a couple of libraries and now we need to use another JDK version. Issue is that right now we need to manually go through each agent and set up new JDK version there.

I am wondering, maybe is there a tool that can configure build agents (or any machine, actually) (I am talking about installing tools, choosing their versions, etc.) in a declarative way. Like having yaml or any other type of file which has all required information and the tool will do anything required to meet requirements defined in a config file.

Docker is already doing something like that, but it's not really declarative and it creates overhead, which is something we can not allow.

3
  • You can provision runners on the fly if the infrastructure that you're using to host them has a decent API. I typically suggest doing this with a Terraform apply, given that you have existing assets (Terraform module and prebuilt image). What are you hosting your runners on? Commented Sep 18, 2023 at 15:45
  • Nothing fancy, it's just a couple of mac minis connected to Git Hub actions as self-hosted agents. I have not looked deep into Terraform, but for the first glance it looks exactly like the tool I was looking for. Thanks! Commented Sep 18, 2023 at 21:40
  • Thanks for the clarification. In that case, I'm sure you've already read the docs for creating new runners. However, since your question was about declatively configuring them. Slightly different. Commented Sep 19, 2023 at 6:56

1 Answer 1

0

If you have Docker on the machines which are hosting the github runners, and you have already registered them with the repos containing the pipelines which will execute them, you have a few options available:

  1. The easiest, but most invasive way of doing this is to use the machines as bare-metal provisioned. I would write an ansible role and playbook (this provides your declarative configuration) to turn a vanilla machine into a provisioned runner.
  2. If you create Github Actions, you can package them into containers (using the same Ansible role and playbook as above), and update your workflow.yml to use these actions or containers on the host. You will have to build the container that the workflow or action needs before. If you want to have a declarative configuration for these containers too, you can write a Packer template.
  3. Finally, customise the the containers that are used by the runner: See https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/customizing-the-containers-used-by-jobs. You can use that to define mount points (for special licensed software, e.g.)

So, to recap and respond directly to the question:

is there a tool that can configure build agents

My choice would be Ansible. Create a repo for the role and playbook. The actions in that repo will provision your hosts every time you merge to main. E.g. a new version of java is approved -> you merge the PR -> Github Actions run Ansible playbook -> runners are now updated.

Alternatively, you use that same Ansible role and playbook to provision containers which are referenced in the application's pipeline; put a Packer template in the same repo as the Ansible role and playbook.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.