fortytwoservices / terraform-azurerm-selfhostedrunnervmss

Module for creating a simple virtual machine scale set for Azure DevOps and GitHub self hosted runners
MIT License
2 stars 2 forks source link

Feature - Assign Runner to a Runner Group #55

Closed tim-chaffin closed 11 months ago

tim-chaffin commented 11 months ago

In this script: https://raw.githubusercontent.com/amestofortytwo/terraform-azurerm-selfhostedrunnervmss/main/scripts/script.sh

We're unable to pass the -r parameter to the create-latest-svc.sh script. This parameter allows us to assign a Runner to a Runner Group. Granted, this is an optional configuration. Could we update the Amesto Fortytwo script to support passing the Runner Group parameter? Perhaps something like this:

Original:

#!/bin/sh
user=$3

cd /home/$user
curl -s https://raw.githubusercontent.com/actions/runner/main/scripts/create-latest-svc.sh > create-latest-svc.sh
chown $user:$user /home/$user/create-latest-svc.sh
chmod 750 /home/$user/create-latest-svc.sh
export RUNNER_CFG_PAT=$2
bash "/home/$user/create-latest-svc.sh" -s $1 -u $user -l $4 -f

Updated:

#!/bin/sh
user=$3

cd /home/$user
curl -s https://raw.githubusercontent.com/actions/runner/main/scripts/create-latest-svc.sh > create-latest-svc.sh
chown $user:$user /home/$user/create-latest-svc.sh
chmod 750 /home/$user/create-latest-svc.sh
export RUNNER_CFG_PAT=$2

# Check if the fifth argument is provided
if [ -n "$5" ]; then
    bash "/home/$user/create-latest-svc.sh" -s $1 -u $user -l $4 -r $5
else
    bash "/home/$user/create-latest-svc.sh" -s $1 -u $user -l $4
fi

Then the documentation for auto registration would be updated as well. https://docs.byfortytwo.com/Self%20Hosted%20Runners/GitHub/step2/#configure-the-vmss-to-auto-register

Original

VMSS=vmss-test-noeast
RG=rg-test-noeast
PAT=ghp_xxx
ORG=amesfortytwo
USER=admin42
LABEL=label1,label2
az vmss extension set --vmss-name $VMSS --name customScript --resource-group $RG \
    --version 2.1 --publisher Microsoft.Azure.Extensions \
    --protected-settings "{\"fileUris\": [\"https://raw.githubusercontent.com/amestofortytwo/terraform-azurerm-selfhostedrunnervmss/main/scripts/script.sh\"],\"commandToExecute\": \"sh script.sh $ORG $PAT $USER $LABEL\"}"

Updated

VMSS=vmss-test-noeast
RG=rg-test-noeast
PAT=ghp_xxx
ORG=amesfortytwo
USER=admin42
LABEL=label1,label2
R_GROUP=Test
az vmss extension set --vmss-name $VMSS --name customScript --resource-group $RG \
    --version 2.1 --publisher Microsoft.Azure.Extensions \
    --protected-settings "{\"fileUris\": [\"https://raw.githubusercontent.com/amestofortytwo/terraform-azurerm-selfhostedrunnervmss/main/scripts/script.sh\"],\"commandToExecute\": \"sh script.sh $ORG $PAT $USER $LABEL $R_GROUP\"}"
mysteq commented 11 months ago

Should be updated now, and thanks for suggesting!

tim-chaffin commented 11 months ago

No, thank you! I appreciate how fast you guys turn things around.