|
1 | 1 | # Operations - GitHub
|
2 | 2 |
|
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. |
0 commit comments