Skip to content

Commit 7edde35

Browse files
authored
Merge pull request #253 from stackhpc/srt-runners
docs: move GH runner README to docs
2 parents ffae5bd + 080f085 commit 7edde35

File tree

3 files changed

+148
-149
lines changed

3 files changed

+148
-149
lines changed

docs/operations/github.md

Lines changed: 146 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,148 @@
11
# Operations - GitHub
22

3-
TODO: cover repository management, GitHub Actions runners, etc.
3+
## GitHub Actions runners
4+
5+
This Terraform configuration deploys a GitHub Actions runner VMs on an
6+
OpenStack cloud for the stackhpc-release-train repository.
7+
8+
### Usage
9+
10+
These instructions show how to use this Terraform configuration
11+
manually. They assume you are running an Ubuntu host that will be used
12+
to run Terraform. The machine should have network access to the VM that
13+
will be created by this configuration.
14+
15+
Install Terraform:
16+
17+
```
18+
wget -qO - terraform.gpg https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/terraform-archive-keyring.gpg
19+
sudo echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/terraform-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/terraform.list
20+
sudo apt update
21+
sudo apt install terraform
22+
```
23+
24+
Clone and initialise the repo:
25+
26+
```
27+
git clone https://github.com/stackhpc/stackhpc-release-train
28+
cd stackhpc-release-train
29+
```
30+
31+
Change to the `terraform/github-runners` directory:
32+
33+
```
34+
cd terraform/github-runners
35+
```
36+
37+
Initialise Terraform:
38+
39+
```
40+
terraform init
41+
```
42+
43+
Create an OpenStack `clouds.yaml` file with your credentials to access an
44+
OpenStack cloud. Alternatively, download one from Horizon. The
45+
credentials should be scoped to the `stackhpc-release` project.
46+
47+
```
48+
cat << EOF > clouds.yaml
49+
---
50+
clouds:
51+
sms-lab:
52+
auth:
53+
auth_url: https://api.sms-lab.cloud:5000
54+
username: <username>
55+
project_name: stackhpc-release
56+
domain_name: default
57+
interface: public
58+
EOF
59+
```
60+
61+
Export environment variables to use the correct cloud and provide a
62+
password:
63+
64+
```
65+
export OS_CLOUD=sms-lab
66+
read -p OS_PASSWORD -s OS_PASSWORD
67+
export OS_PASSWORD
68+
```
69+
70+
Verify that the Terraform variables in `terraform.tfvars` are correct.
71+
72+
Generate a plan:
73+
74+
```
75+
terraform plan
76+
```
77+
78+
Apply the changes:
79+
80+
```
81+
terraform apply -auto-approve
82+
```
83+
84+
Create a virtualenv:
85+
86+
```
87+
python3 -m venv venv
88+
```
89+
90+
Activate the virtualenv:
91+
92+
```
93+
source venv/bin/activate
94+
```
95+
96+
Install Python dependencies:
97+
98+
```
99+
pip install -r ansible/requirements.txt
100+
```
101+
102+
Install Ansible Galaxy dependencies:
103+
104+
```
105+
ansible-galaxy collection install -r ansible/requirements.yml
106+
ansible-galaxy role install -r ansible/requirements.yml
107+
```
108+
109+
Create a GitHub PAT token (classic) with repo:all scope. Export an
110+
environment variable with the token.
111+
112+
```
113+
read -p PERSONAL_ACCESS_TOKEN -s PERSONAL_ACCESS_TOKEN
114+
export PERSONAL_ACCESS_TOKEN
115+
```
116+
117+
Deploy runners:
118+
119+
```
120+
ansible-playbook ansible/site.yml -i ansible/inventory.yml
121+
```
122+
123+
To remove runners:
124+
125+
```
126+
ansible-playbook ansible/site.yml -i ansible/inventory.yml -e runner_state=absent
127+
```
128+
129+
### Troubleshooting
130+
131+
#### Install service fails
132+
133+
If you see the following:
134+
135+
```
136+
TASK [monolithprojects.github_actions_runner : Install service] ********************************************************************************************************************************************
137+
fatal: [10.205.0.50]: FAILED! => changed=true
138+
cmd: ./svc.sh install ubuntu
139+
msg: '[Errno 2] No such file or directory: b''./svc.sh'''
140+
rc: 2
141+
stderr: ''
142+
stderr_lines: <omitted>
143+
stdout: ''
144+
stdout_lines: <omitted>
145+
```
146+
147+
It might mean the runner is already registered, possibly from a previous
148+
VM. Remove the runner using Ansible or the GitHub settings.

terraform/github-runners/README.rst

Lines changed: 0 additions & 148 deletions
This file was deleted.

terraform/github-runners/ansible/site.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
name: monolithprojects.github_actions_runner
1414
become: true
1515

16+
# FIXME: Sometimes the runner service is not running at the end of the role.
17+
# Start the service manually.
1618
- name: Ensure runner service is running
1719
ansible.builtin.service:
1820
name: actions.runner.stackhpc-stackhpc-release-train.{{ ansible_facts.hostname }}.service

0 commit comments

Comments
 (0)