Skip to content
Snippets Groups Projects
Commit 16803e54 authored by Erick Hitter's avatar Erick Hitter
Browse files

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

parent 1a794993
No related branches found
No related tags found
1 merge request!1Support runner options for Docker Machine
...@@ -12,47 +12,69 @@ This role requires Ansible 2.0 or higher. ...@@ -12,47 +12,69 @@ This role requires Ansible 2.0 or higher.
Role Variables 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`. **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. The maximum number of global jobs to run concurrently.
Defaults to the number of processor cores. 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. 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. The GitLab coordinator URL.
Defaults to `https://gitlab.com/ci`. Defaults to `https://gitlab.com/ci`.
`gitlab_runner_description` ###### `gitlab_runner_description_base`
The description of the runner. Base description of the runner.
Defaults to the hostname. Defaults to the hostname.
`gitlab_runner_executor` ###### `gitlab_runner_executor`
The executor used by the runner. The executor used by the runner.
Defaults to `shell`. Defaults to `shell`.
`gitlab_runner_concurrent_specific` ###### `gitlab_runner_concurrent_specific`
The maximum number of jobs to run concurrently on this specific runner. The maximum number of jobs to run concurrently on this specific runner.
Defaults to 0, simply means don't limit. 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`. The default Docker image to use. Required when executor is `docker`.
`gitlab_runner_tags` ###### `gitlab_runner_tags`
The tags assigned to the runner,
Default tags assigned to the runner,
Defaults to an empty list. Defaults to an empty list.
`gitlab_runner_cache_type` ###### `gitlab_runners`
Variables to set s3 as a shared cache server. If set it requires variables listed below:
`gitlab_runner_cache_s3_server_address` Dict of runners
`gitlab_runner_cache_s3_access_key`
`gitlab_runner_cache_s3_access_key` ```yml
`gitlab_runner_cache_s3_bucket_name` gitlab_runners:
`gitlab_runner_cache_s3_insecure` - {
`gitlab_runner_cache_cache_shared` 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) 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' ...@@ -10,7 +10,7 @@ gitlab_runner_coordinator_url: 'https://gitlab.com/ci'
# GitLab registration token # GitLab registration token
gitlab_runner_registration_token: '' gitlab_runner_registration_token: ''
# Runner description # Runner description
gitlab_runner_description: '{{ ansible_hostname }}' gitlab_runner_description_base: '{{ ansible_hostname }}'
# Runner executor # Runner executor
gitlab_runner_executor: 'shell' gitlab_runner_executor: 'shell'
# Maximum number of jobs to run concurrently on this specific runner # Maximum number of jobs to run concurrently on this specific runner
...@@ -32,11 +32,17 @@ gitlab_runner_ssh_password: '' ...@@ -32,11 +32,17 @@ gitlab_runner_ssh_password: ''
# Runner SSH identity file # Runner SSH identity file
gitlab_runner_ssh_identity_file: '' gitlab_runner_ssh_identity_file: ''
# Runner Locked # Runner Locked
gitlab_runner_locked: 'false' gitlab_runner_locked: false
# Individual runners
gitlab_runners:
- {
description: '{{ gitlab_runner_description_base }}'
}
# Runner machine # Runner machine
gitlab_runner_machine_idle_nodes: 0 gitlab_runner_machine_idle_nodes: 0
gitlab_runner_machine_idle_time: 2 gitlab_runner_machine_idle_time: 3
# Docker Machine # Docker Machine
docker_machine_version: 'v0.15.0' docker_machine_version: 'v0.15.0'
......
--- ---
galaxy_info: galaxy_info:
author: Erik-jan Riemers author: Erick Hitter, Erik-jan Riemers
description: GitLab Runner description: GitLab Runner
license: MIT license: MIT
min_ansible_version: 2.0 min_ansible_version: 2.0
platforms: platforms:
- name: EL - name: Debian
versions: version:
- all - all
- name: Ubuntu
versions:
- all
- name: Debian
version:
- all
galaxy_tags: galaxy_tags:
- gitlab - gitlab
- runner - runner
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
command: gitlab-runner register > command: gitlab-runner register >
--non-interactive --non-interactive
--url '{{ gitlab_runner_coordinator_url }}' --url '{{ gitlab_runner_coordinator_url }}'
--registration-token '{{ gitlab_runner_registration_token }}' --registration-token '{{ item.token | default( gitlab_runner_registration_token ) }}'
--description '{{ gitlab_runner_description }}' --description '{{ item.description }}'
--tag-list '{{ gitlab_runner_tags | join(",") }}' --tag-list '{{ ( item.tags | default( gitlab_runner_tags ) ) | join(",") }}'
--executor '{{ gitlab_runner_executor }}' --executor '{{ gitlab_runner_executor }}'
--limit '{{ gitlab_runner_concurrent_specific }}' --limit '{{ gitlab_runner_concurrent_specific }}'
--locked='{{gitlab_runner_locked}}' --locked='{{ item.locked | default( gitlab_runner_locked ) }}'
--docker-image '{{ gitlab_runner_docker_image }}' --docker-image '{{ gitlab_runner_docker_image }}'
{% if gitlab_runner_docker_volumes is defined %} {% if gitlab_runner_docker_volumes is defined %}
--docker-volumes "{{ gitlab_runner_docker_volumes | join('" "') }}" --docker-volumes "{{ gitlab_runner_docker_volumes | join('" "') }}"
...@@ -43,4 +43,5 @@ ...@@ -43,4 +43,5 @@
--machine-machine-options 'digitalocean-region={{ gitlab_runner_digital_ocean_region }}' --machine-machine-options 'digitalocean-region={{ gitlab_runner_digital_ocean_region }}'
--machine-machine-options 'digitalocean-size={{ gitlab_runner_digital_ocean_size }}' --machine-machine-options 'digitalocean-size={{ gitlab_runner_digital_ocean_size }}'
--machine-machine-options 'digitalocean-private-networking' --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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment