https://github.com/stackhpc/gitlab-runner-openstack
https://github.com/stackhpc/gitlab-runner-openstack
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/stackhpc/gitlab-runner-openstack
- Owner: stackhpc
- Created: 2022-07-27T09:22:02.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-04T13:59:35.000Z (about 2 years ago)
- Last Synced: 2024-04-14T22:50:20.122Z (about 2 years ago)
- Language: HCL
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gitlab-runner-openstack
This repository contains some simple [OpenTofu](https://opentofu.org) that
uses Cloud-Init to launch a [GitLab CI runner](https://docs.gitlab.com/runner/) in an
[OpenStack](https://www.openstack.org/) project that uses the
[Docker executor](https://docs.gitlab.com/runner/executors/docker.html).
## Usage
First, ensure
[OpenTofu is installed](https://opentofu.org/docs/intro/install/).
Next, make sure you have credentials for the target OpenStack project. The following
examples will assume the use of a
[clouds.yaml](https://docs.openstack.org/python-openstackclient/latest/configuration/index.html#clouds-yaml)
file, preferably containing an
[Application Credential](https://docs.openstack.org/keystone/latest/user/application_credentials.html).
You will also need the host and registration token for registering a runner with the
target GitLab instance. These can be found in the runners panel at either the global
(admin required), group or project level.
Next, clone this repository:
```sh
git clone https://github.com/stackhpc/gitlab-runner-openstack.git
cd gitlab-runner-openstack
```
Create a
[tfvars](https://opentofu.org/docs/language/values/variables/#variable-definitions-tfvars-files)
file to configure the runner:
```ruby
## FILE: my-runner.tfvars
# The ID of the network to provision the runner on
# Must be able to reach the internet, but does not have to be reachable from the internet
network_id = ""
# The ID of an Ubuntu 22.04 image to use
image_id = ""
# The name of the flavor to use for the runner
flavor_name = ""
# The GitLab host to connect to
gitlab_host = ""
# The token to use when registering the runner
registration_token = ""
```
Then execute the following commands to deploy a runner:
```sh
# OpenStack authentication
export OS_CLOUD=openstack
export OS_CLIENT_CONFIG_FILE=/path/to/clouds.yaml
# Init the OpenTofu state
tofu init
# Provision the runner
tofu apply -var-file=./my-runner.tfvars -auto-approve
```