You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am setting up a group of VMs to work as github action runners in a hetzner dedicated machine. Everything is installed as expected, but the ansible playbook for the role MonolithProjects.github_actions_runner is executed, in some of the machines it fails with a timeout in the registry of the runner:
The definition of the Vagrant file can be seen here:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vagrant.plugins = ["vagrant-libvirt"]
config.vm.provider "libvirt"
(1..3).each do |index|
config.vm.define "mozart-gh-actions#{index}" do |node|
node.vm.hostname = "mozart-gh-actions"
node.vm.box = "generic/ubuntu2204"
node.vm.network "private_network", ip: "192.168.121.#{index + 1}"
node.vm.synced_folder ".", "/home/vagrant/work", type: "nfs", nfs_version: 4, mount_options: ["tcp"]
node.vm.provider "libvirt" do |lb|
# do not change this to qemu. Dotnet does not work with qemu.
lb.driver = "kvm"
lb.memory = 4096
lb.cpus = 4
end
node.vm.provision "init", type: "shell" do |shell|
shell.path ="./bootstrap.sh"
shell.args = ["hetzner-#{ENV["VM_NAME"]}-vm#{index}", "<NAME OF THE ORG>", "#{ENV["GITHUB_TOKEN"]}"]
end
node.vm.provision "ansible_local", after: "init" do |ansible|
ansible.playbook = "gha-playbook.yml"
ansible.galaxy_role_file = "requirements.yml"
ansible.provisioning_path = "/home/vagrant/work"
ansible.extra_vars = {
"access_token" => "#{ENV["GITHUB_TOKEN"]}",
"github_account" => "<NAME OF THE ORG>",
"runner_user" => "vagrant",
"runner_name" => "hetzner-#{ENV["VM_NAME"]}-vm#{index}",
"runner_group" => "labgrid",
"runner_dir" => "/home/vagrant/actions-runner",
"runner_org" => true,
"runner_labels" => ["self-hosted", "Linux", "X64"],
"hide_sensitive_logs" => false
}
end
end
end
end
This is the bootstrap.sh script:
#!/bin/bash
# Commands for the startup of every VM
if [ "$#" -ne 3 ]; then
echo "Name of the runner, of the organization and the gh token are expected"
exit 1
fi
# Install basic dependencies
apt update -y
apt install net-tools curl -y
apt install -y software-properties-common libgnutls30 ca-certificates apt-transport-https
sudo update-ca-certificates
apt update -y
apt install -y jq
# Setup to install ansible
apt-add-repository ppa:ansible/ansible
apt update -y
apt install -y ansible
# Install nodejs
apt install -y nodejs
# Install docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh
groupadd docker
gpasswd -a vagrant docker
# Check if runner exists, cleaning it in advance
python3 /home/vagrant/work/clean_gha_runner.py $1 $2 $3
# Disable IPv6 for GH Actions
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" >> /etc/sysctl.conf
sudo sysctl -p
This is the clean_gha_runner.py:
"""
Search for all the github runners and deletes the one reffering to the machine,
if it exists in the list.
"""
import requests
import sys
print("--- Clean Registered GH Actions Runner ---")
if len(sys.argv) != 4:
print("Script requires 3 execution arguments: runner_name, org_name, token")
print(f"Arguments passed: {sys.argv[1:]}")
sys.exit(1)
runner_name: str = sys.argv[1]
get_request: str = f"https://api.github.com/orgs/{sys.argv[2]}/actions/runners"
del_request: str = f"https://api.github.com/orgs/{sys.argv[2]}/actions/runners"
headers: dict[str, str] = {
"Authorization": f"Bearer {sys.argv[3]}",
"X-GitHub-Api-Version": "2022-11-28",
"Accept": "application/vnd.github+json"
}
response: requests.Response = requests.get(
get_request,
headers=headers)
print(f"Status code of runners request: {response.status_code}")
if "runners" in response.json():
runner_list: list[dict[str,object]] = response.json()["runners"]
print("Searching for the existing runner")
for runner in runner_list:
if runner["name"] == runner_name:
print(f"Found runner {runner_name} with id {runner['id']}")
requests.delete(f"{del_request}/{runner['id']}", headers=headers)
print("Deletion of runner executed")
sys.exit(0)
print(f"No runner with name {runner_name} found")
print('No "runners" key found in request body. Skipped deletion of runners')
# role to install GH Actions runner in the VM
---
- name: Install GitHub Actions Runner on bang-olufsen VM runners
hosts: all
user: vagrant
become: true
roles:
- role: MonolithProjects.github_actions_runner
Expected behavior
For all VMs to configure the runner successfully and show an output similar to this:
...
Mar 18 11:39:43 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : Register runner] ****************
Mar 18 11:39:48 mozart06 vagrant[3104952]: changed: [mozart-gh-actions2]
Mar 18 11:39:48 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : Update runner labels if changed] ***
Mar 18 11:39:48 mozart06 vagrant[3104952]: skipping: [mozart-gh-actions2]
Mar 18 11:39:48 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : Replace registered runner] ******
Mar 18 11:39:48 mozart06 vagrant[3104952]: skipping: [mozart-gh-actions2]
Mar 18 11:39:48 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : Install service] ****************
Mar 18 11:39:48 mozart06 vagrant[3104952]: changed: [mozart-gh-actions2]
Mar 18 11:39:48 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : Read service name from file] ****
Mar 18 11:39:48 mozart06 vagrant[3104952]: ok: [mozart-gh-actions2]
Mar 18 11:39:48 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : START and enable Github Actions Runner service (Linux)] ***
Mar 18 11:39:49 mozart06 vagrant[3104952]: changed: [mozart-gh-actions2]
Mar 18 11:39:49 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : START and enable Github Actions Runner service (macOS)] ***
Mar 18 11:39:49 mozart06 vagrant[3104952]: skipping: [mozart-gh-actions2]
Mar 18 11:39:49 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : STOP and disable Github Actions Runner service] ***
Mar 18 11:39:49 mozart06 vagrant[3104952]: skipping: [mozart-gh-actions2]
Mar 18 11:39:49 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : Version changed - RESTART Github Actions Runner service] ***
Mar 18 11:39:54 mozart06 vagrant[3104952]: changed: [mozart-gh-actions2]
Mar 18 11:39:54 mozart06 vagrant[3104952]: TASK [MonolithProjects.github_actions_runner : Include tasks to install runner (Windows)] ***
Mar 18 11:39:54 mozart06 vagrant[3104952]: skipping: [mozart-gh-actions2]
Mar 18 11:39:54 mozart06 vagrant[3104952]: PLAY RECAP *********************************************************************
Mar 18 11:39:54 mozart06 vagrant[3104952]: mozart-gh-actions2 : ok=27 changed=7 unreachable=0 failed=0 skipped=23 rescued=0 ignored=1
Actual behavior
Some runners do not get registered with a timeout:
Description
I am setting up a group of VMs to work as github action runners in a hetzner dedicated machine. Everything is installed as expected, but the ansible playbook for the role
MonolithProjects.github_actions_runner
is executed, in some of the machines it fails with a timeout in the registry of the runner:The definition of the Vagrant file can be seen here:
This is the
bootstrap.sh
script:This is the
clean_gha_runner.py
:This is the
requirements.yml
:This is the
gha-playbook.yml
:Expected behavior
For all VMs to configure the runner successfully and show an output similar to this:
Actual behavior
Some runners do not get registered with a timeout:
These are the logs inside the
_diag_folder
:Repro steps
This is a quick run down of the instructions that should be followed. In a ubuntu 22.04 system do the following:
GITHUB_TOKEN
with the github developer token with the proper permissions andVM_NAME
vagrant up --provider libvirt --no-parallel
This is the ansible playbook executed on the machine:
The text was updated successfully, but these errors were encountered: