This guide assumes that the user already has a VM running on SURF HPC Cloud.
We will use an Ansible playbook to install a GitHub Action runner on it. When done a GitHub action workflow configured with runs-on: self-hosted
will run on that runner in the VM.
- VM running on SURF HPC Cloud
- Ansible version 2.9.10 or later
- Option 1 - Using a Python virtual environment and
pip install ansible
. - Option 2 - Using package manager (tested on Ubuntu 20.04)
sudo apt update sudo apt install ansible
- Option 1 - Using a Python virtual environment and
To deploy the runner on SURF HPC Cloud, we need to create a Virtual machine (VM). You can find the instructions here.
In order to access to VM, you will need to create ssh keys. Please see this link
If you want to test the connection with the VM, you can use the command below
ssh -i $YOUR_KEY_PATH -p 22 $USER@$HOSTNAME
In this command,
$HOSTNAME
is the IP address of the VM you created,$YOUR_KEY_PATH
is the ssh key you generated in previous step.$USER
is the posix user on the vm associated with the ssh key.
To use Ansible you need an inventory file. An example inventory file called hosts.example
should be copied to hosts
and updated to reflect your situation.
cp hosts.example hosts
Ansible playbook will ask for which GitHub account/organization and repository it should setup a runner for.
When Ansible command is executed, the Ansible playbook will ask for
- the user or rganization name
- the repository name
As a repository, you can use a clone of https://github.com/ci-for-science/example-python-1 or any repository which has a GitHub Action workflow that has runs-on: self-hosted
.
The Ansible playbook uses Personal Access Token for GitHub account to register the runner.
The token needs to have full admin rights for the repo. The only scope needed is repo Full control of private repositories
.
The token can be created here.
The generated token should be set as the PAT
environment variable.
export PAT=xxxxxxxxxxxxxxx
To install GitHub Action runner we use an Ansible playbook to provision the VM.
To test the connection with the server, Ansible can run ping command.
ansible all -m ping
If it successfully connects to the server, the output should be something like
hpc | SUCCESS => {
"changed": false,
"ping": "pong"
}
The playbook uses roles from Ansible galaxy, they must be downloaded with
ansible-galaxy install -r requirements.yml
To provision VM use
ansible-playbook --ask-become-pass playbook.yml
To view the log of the runner, you can connect to the server via ssh and run
journalctl -u actions.runner.*
First unregister runner with
ansible-playbook --ask-become-pass playbook.yml --tags uninstall