Commit 16803e54 authored by Erick Hitter's avatar Erick Hitter

Support multiple GitLab runners, with option for runner-specific tokens

parent 1a794993
......@@ -12,47 +12,69 @@ This role requires Ansible 2.0 or higher.
Role Variables
--------------
`gitlab_runner_package_name`
###### `gitlab_runner_package_name`
**Since Gitlab 10.x** The package name of `gitlab-ci-multi-runner` has been renamed to `gitlab-runner`. In order to install a version >= 10.x you will need to define this variable `gitlab_runner_package_name: gitlab-runner`.
`gitlab_runner_concurrent`
###### `gitlab_runner_concurrent`
The maximum number of global jobs to run concurrently.
Defaults to the number of processor cores.
`gitlab_runner_registration_token`
###### `gitlab_runner_registration_token`
The GitLab registration token. If this is specified, a runner will be registered to a GitLab server.
`gitlab_runner_coordinator_url`
###### `gitlab_runner_coordinator_url`
The GitLab coordinator URL.
Defaults to `https://gitlab.com/ci`.
`gitlab_runner_description`
The description of the runner.
###### `gitlab_runner_description_base`
Base description of the runner.
Defaults to the hostname.
`gitlab_runner_executor`
###### `gitlab_runner_executor`
The executor used by the runner.
Defaults to `shell`.
`gitlab_runner_concurrent_specific`
###### `gitlab_runner_concurrent_specific`
The maximum number of jobs to run concurrently on this specific runner.
Defaults to 0, simply means don't limit.
`gitlab_runner_docker_image`
###### `gitlab_runner_docker_image`
The default Docker image to use. Required when executor is `docker`.
`gitlab_runner_tags`
The tags assigned to the runner,
###### `gitlab_runner_tags`
Default tags assigned to the runner,
Defaults to an empty list.
`gitlab_runner_cache_type`
Variables to set s3 as a shared cache server. If set it requires variables listed below:
`gitlab_runner_cache_s3_server_address`
`gitlab_runner_cache_s3_access_key`
`gitlab_runner_cache_s3_access_key`
`gitlab_runner_cache_s3_bucket_name`
`gitlab_runner_cache_s3_insecure`
`gitlab_runner_cache_cache_shared`
###### `gitlab_runners`
Dict of runners
```yml
gitlab_runners:
- {
description: '{{ gitlab_runner_description_base }}',
tags: [],
locked: false,
token: ''
}
```
###### `gitlab_runner_cache_type`
Variables to set `s3` as a shared cache server. If set it requires variables listed below:
* `gitlab_runner_cache_s3_server_address`
* `gitlab_runner_cache_s3_access_key`
* `gitlab_runner_cache_s3_secret_key`
* `gitlab_runner_cache_s3_bucket_name`
* `gitlab_runner_cache_s3_insecure`
* `gitlab_runner_cache_cache_shared`
See the [config for more options](https://github.com/riemers/ansible-gitlab-runner/blob/master/tasks/register-runner.yml)
......
......@@ -10,7 +10,7 @@ gitlab_runner_coordinator_url: 'https://gitlab.com/ci'
# GitLab registration token
gitlab_runner_registration_token: ''
# Runner description
gitlab_runner_description: '{{ ansible_hostname }}'
gitlab_runner_description_base: '{{ ansible_hostname }}'
# Runner executor
gitlab_runner_executor: 'shell'
# Maximum number of jobs to run concurrently on this specific runner
......@@ -32,11 +32,17 @@ gitlab_runner_ssh_password: ''
# Runner SSH identity file
gitlab_runner_ssh_identity_file: ''
# Runner Locked
gitlab_runner_locked: 'false'
gitlab_runner_locked: false
# Individual runners
gitlab_runners:
- {
description: '{{ gitlab_runner_description_base }}'
}
# Runner machine
gitlab_runner_machine_idle_nodes: 0
gitlab_runner_machine_idle_time: 2
gitlab_runner_machine_idle_time: 3
# Docker Machine
docker_machine_version: 'v0.15.0'
......
---
galaxy_info:
author: Erik-jan Riemers
author: Erick Hitter, Erik-jan Riemers
description: GitLab Runner
license: MIT
min_ansible_version: 2.0
platforms:
- name: EL
versions:
- all
- name: Ubuntu
versions:
- all
- name: Debian
version:
- all
- name: Debian
version:
- all
galaxy_tags:
- gitlab
- runner
......
......@@ -9,12 +9,12 @@
command: gitlab-runner register >
--non-interactive
--url '{{ gitlab_runner_coordinator_url }}'
--registration-token '{{ gitlab_runner_registration_token }}'
--description '{{ gitlab_runner_description }}'
--tag-list '{{ gitlab_runner_tags | join(",") }}'
--registration-token '{{ item.token | default( gitlab_runner_registration_token ) }}'
--description '{{ item.description }}'
--tag-list '{{ ( item.tags | default( gitlab_runner_tags ) ) | join(",") }}'
--executor '{{ gitlab_runner_executor }}'
--limit '{{ gitlab_runner_concurrent_specific }}'
--locked='{{gitlab_runner_locked}}'
--locked='{{ item.locked | default( gitlab_runner_locked ) }}'
--docker-image '{{ gitlab_runner_docker_image }}'
{% if gitlab_runner_docker_volumes is defined %}
--docker-volumes "{{ gitlab_runner_docker_volumes | join('" "') }}"
......@@ -43,4 +43,5 @@
--machine-machine-options 'digitalocean-region={{ gitlab_runner_digital_ocean_region }}'
--machine-machine-options 'digitalocean-size={{ gitlab_runner_digital_ocean_size }}'
--machine-machine-options 'digitalocean-private-networking'
when: configured_runners.stderr.find('\n' + gitlab_runner_description) == -1
with_items: '{{ gitlab_runners }}'
when: configured_runners.stderr.find('\n' + item.description) == -1
[runner_{{ gitlab_runner_package_name }}]
name=runner_{{ gitlab_runner_package_name }}
baseurl=https://packages.gitlab.com/runner/{{ gitlab_runner_package_name }}/el/{{ ansible_distribution_major_version }}/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
[runner_{{ gitlab_runner_package_name }}-source]
name=runner_{{ gitlab_runner_package_name }}-source
baseurl=https://packages.gitlab.com/runner/{{ gitlab_runner_package_name }}/el/{{ ansible_distribution_major_version }}/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment