GitLab Runner
This role installs the gitlab-runner
agent and registers
runners.
Requirements
This role requires Ansible 2.0 or higher.
Role Variables
Variable | Default | Purpose |
---|---|---|
gitlab_runner_package |
gitlab-runner |
As of GitLab 9.0, the GitLab Runner package has started using version 4 of the GitLab API and has been renamed to gitlab-runner . If you need to support GitLab versions prior to v9.0 then you need to use the older GitLab Runner package by setting this variable to gitlab-ci-multi-runner . |
gitlab_runner_install |
true |
Asserts whether to install the GitLab Runner agent. |
gitlab_runner_register |
true |
Asserts whether to register a runner. |
Runner Agent Variables
These variables are used to configure the gitlab-runner
agent, and thus affect
all runners registered with this agent.
Variable | Default | Purpose |
---|---|---|
gitlab_runner_user |
gitlab-runner |
The username of the user that will be created to run the runner agent. |
gitlab_runner_groups |
[] |
Additional groups that the gitlab_runner_user should belong to. |
gitlab_runner_shell |
/bin/bash |
The shell that the gitlab_runner_user should use. |
gitlab_runner_sudo_cmds |
[] |
Specific shelll commands that the gitlab_runner_user can run as sudo , without a password. |
gitlab_runner_concurrent_jobs |
2 | The number of concurrent jobs that can be executed by this runner |
gitlab_runner_check_interval |
5 | How often the agent should check for new pending jobs. Value is in seconds. |
gitlab_runner_privkey |
'' |
Private SSH key which is added to the gitlab_runner_user for use as a deploy key. |
gitlab_runner_pubkey |
'' |
The public SSH key that matches the gitlab_runner_privkey . This is set up as a global deploy key in GitLab so all you have to do it enable that deploy key on your project. |
Per-Runner Variables
You can register multiple runners with this role and all these variables below can be configured per runner.
Variable | Default | Purpose |
---|---|---|
gitlab_runner_url |
'' |
REQUIRED The GitLab CI coordinator URL. |
gitlab_runner_token |
'' |
REQUIRED A runner registration token for a project. These are unique per GitLab project. |
gitlab_runner_description |
{{ansible_hostname}} |
The name/description of the runner. |
gitlab_runner_executor |
shell |
The executor for this runner. Currently only supports shell .
|
gitlab_runner_tags |
[] |
List of tags for which the runner should accept jobs. If not empty, then the runner will only run tagged jobs. |
gitlab_runner_locked |
true |
Asserts whether the runner should be locked to the project. |
Example Playbook
This is the basic way to use this role. This will install the GitLab Runner agent, and register a single runner.
- hosts: servers
roles:
- { role: gitlab-runner, gitlab_runner_url: https://gitlab.com/ci, gitlab_runner_token: <registration-token> }
It is also possible to register multiple runners by running the role multiple times. The first run will install the agent and register the first runner, then each subsequent run will register another runner.
- hosts: servers
tasks:
- include_role:
name: gitlab-runner
vars:
gitlab_runner_url: https://gitlab.com/ci
gitlab_runner_token: <registration-token>
gitlab_runner_description: runner-1
- include_role:
name: gitlab-runner
vars:
gitlab_runner_install: false
gitlab_runner_url: https://gitlab.com/ci
gitlab_runner_token: <registration-token>
gitlab_runner_description: runner-2