From 59ec6bf8b44de30f0a5e8ade9ea84c5c17e6ce6f Mon Sep 17 00:00:00 2001 From: Steve Traylen Date: Mon, 3 Jul 2023 21:38:12 +0200 Subject: [PATCH] Support adding runner to runner groups Allow a per instance `runner_group` to be specified to pupulate the `--runnergroup` option to `config.sh` * https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/managing-access-to-self-hosted-runners-using-groups --- README.md | 1 + manifests/instance.pp | 4 ++++ templates/configure_install_runner.sh.epp | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 5293df5..e689b8d 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ github_actions_runner::instances: example_org_instance: labels: - self-hosted-custom + runner_group: 'MyRunners' ``` Note, your `personal_access_token` has to contain the `admin:org` permission. diff --git a/manifests/instance.pp b/manifests/instance.pp index 90c8dde..8703666 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -44,6 +44,8 @@ # * labels # Optional[Array[String]], A list of costum lables to add to a runner. # +# * runner_group +# Optional[String[1]], The github runner group to add the runner to. # * path # Optional[Array[String]], List of paths to be used as PATH env in the instance runner. If not defined, file ".path" will be kept as created # by the runner scripts. (Default: Value set by github_actions_runner Class) @@ -67,6 +69,7 @@ Optional[String[1]] $no_proxy = $github_actions_runner::no_proxy, Optional[Boolean] $disable_update = $github_actions_runner::disable_update, Optional[Array[String[1]]] $labels = undef, + Optional[String[1]] $runner_group = undef, Optional[String[1]] $enterprise_name = $github_actions_runner::enterprise_name, Optional[String[1]] $org_name = $github_actions_runner::org_name, Optional[String[1]] $repo_name = undef, @@ -139,6 +142,7 @@ url => $url, hostname => $hostname, assured_labels => $assured_labels, + runner_group => $runner_group, disable_update => $disable_update, }), notify => Exec["${instance_name}-run_configure_install_runner.sh"], diff --git a/templates/configure_install_runner.sh.epp b/templates/configure_install_runner.sh.epp index bc5abe2..e2317ca 100644 --- a/templates/configure_install_runner.sh.epp +++ b/templates/configure_install_runner.sh.epp @@ -5,6 +5,7 @@ String $url, String $hostname, String $assured_labels, + Optional[String[1]] $runner_group = undef, Boolean $disable_update, | -%> #!/bin/bash @@ -33,6 +34,9 @@ export RUNNER_ALLOW_RUNASROOT=true --name <%= $hostname %>-<%= $instance_name %> \ --url <%= $url %> \ --token ${TOKEN} \ + <%- if $runner_group { -%> + --runnergroup <%= $runner_group %> \ + <%- } -%> <%- if $disable_update { -%> --disableupdate \ <%- } -%>