An open API service indexing awesome lists of open source software.

https://github.com/redhatqe/openstack-gitlab-executor

Custom GitLab executor for running jobs on Openstack instances
https://github.com/redhatqe/openstack-gitlab-executor

gitlab-ci openstack

Last synced: 8 months ago
JSON representation

Custom GitLab executor for running jobs on Openstack instances

Awesome Lists containing this project

README

          

# GitLab CI Openstack executor

GitLab CI doesn't support Openstack as an executor but provides the ability to implement your own
executor by using scripts to provision, run, and clean up CI environment. This repository contains
such scripts as well as a Containerfile to build and configure a container image with Gitlab Runner
that uses custom Openstack executor.

## Building

```sh
git clone https://github.com/RedHatQE/openstack-gitlab-executor.git
cd openstack-gitlab-executor
podman build --build-arg GITLAB_RUNNER_VERSION= -f Containerfile -t openstack-gitlab-runner
```

## Configuration

The container expects the following environment variables:

### Instance variables

`FLAVOR` - Default instance flavor reference

`BUILDER_IMAGE` - Default image to use for instance provisioning

`NETWORK` - Default network name

`KEY_PAIR_NAME` - Default SSH key pair name

`SECURITY_GROUP` - Default security group

`USERNAME` - Default username for SSH connection to instances

`PRIVATE_KEY` - Private key content

`SSH_TIMEOUT` - Timeout for establishing SSH connection

### GitLab Runner variables

`RUNNER_TAG_LIST` - Tag list

`REGISTRATION_TOKEN` - Runner's registration token

`RUNNER_NAME` - Runner name

`CI_SERVER_URL` - Runner URL

`RUNNER_BUILDS_DIR` - Path to `builds` directory on the Openstack instance

`RUNNER_CACHE_DIR` - Path to `cache` directory on the Openstack instance

`CONCURRENT` - Limits how many jobs can run concurrently (default 1)

### [Openstack variables](https://docs.openstack.org/python-openstackclient/latest/cli/man/openstack.html#environment-variables)

`OS_AUTH_URL` - Openstack authentication URL

`OS_PROJECT_NAME` - Project-level authentication scope (name or ID)

`OS_USERNAME` - Authentication username

`OS_PASSWORD` - Authentication password

`OS_PROJECT_DOMAIN_NAME` - Domain name or ID containing project

`OS_USER_DOMAIN_NAME` - Domain name or ID containing user

`OS_REGION_NAME` - Authentication region name

`OS_IDENTITY_API_VERSION` - Identity API version

`OS_INTERFACE` - Interface type

## Usage

Create an env file with all variables:

```sh
cat env.txt

RUNNER_TAG_LIST=
REGISTRATION_TOKEN=
RUNNER_NAME=
CI_SERVER_URL=
RUNNER_BUILDS_DIR=
RUNNER_CACHE_DIR=
CONCURRENT=

FLAVOR=
BUILDER_IMAGE=
NETWORK=
KEY_PAIR_NAME=
SECURITY_GROUP=
USERNAME=

OS_AUTH_URL=
OS_PROJECT_NAME=
OS_USERNAME=
OS_PASSWORD=
OS_PROJECT_DOMAIN_NAME=
OS_USER_DOMAIN_NAME=
OS_REGION_NAME=
OS_IDENTITY_API_VERSION=
OS_INTERFACE=
```

Run a container:

```sh
podman run -it \
-e PRIVATE_KEY="$(cat )"
--env-file=env.txt \
quay.io/redhatqe/openstack-gitlab-runner:latest
```

You can override instance configuration defaults by providing environment variables in a GitLab CI
job config. For example, if you want to use another Openstack image to provision builder instance
you should provide the following:

```yaml
stages:
- build

build:
stage: build
variables:
BUILDER_IMAGE: my-custom-image
tags:
- some-tag
script:
- some command
```