README.md 3.33 KB
Newer Older
Erick Hitter's avatar
Erick Hitter committed
1
GitLab Runner [![pipeline status](https://git.ethitter.com/ansible/gitlab-runner/badges/master/pipeline.svg)](https://git.ethitter.com/ansible/gitlab-runner/commits/master)
Harold Barker's avatar
Harold Barker committed
2 3
=============

Erick Hitter's avatar
Erick Hitter committed
4
Install GitLab Runner using Docker Machine and Digital Ocean for on-demand instance creation. See https://www.digitalocean.com/community/tutorials/how-to-autoscale-gitlab-continuous-deployment-with-gitlab-runner-on-digitalocean.
Erick Hitter's avatar
Erick Hitter committed
5 6

This is intended to be installed on the same host as the GitLab instance, spinning up hosts as needed and quickly tearing them down. If your CI activity is frequent, the `gitlab_runner_machine_idle_time` variable should be increased so hosts can be reused.
Harold Barker's avatar
Harold Barker committed
7 8 9 10 11 12 13 14 15

Requirements
------------

This role requires Ansible 2.0 or higher.

Role Variables
--------------

16 17
###### `gitlab_runner_package_name`

18 19
**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`.

20 21
###### `gitlab_runner_concurrent`

22
The maximum number of global jobs to run concurrently.
Harold Barker's avatar
Harold Barker committed
23 24
Defaults to the number of processor cores.

25 26
###### `gitlab_runner_registration_token`

Harold Barker's avatar
Harold Barker committed
27 28
The GitLab registration token. If this is specified, a runner will be registered to a GitLab server.

29 30
###### `gitlab_runner_coordinator_url`

Harold Barker's avatar
Harold Barker committed
31
The GitLab coordinator URL.
Harold Barker's avatar
Harold Barker committed
32
Defaults to `https://gitlab.com/ci`.
Harold Barker's avatar
Harold Barker committed
33

34 35
###### `gitlab_runner_description_base`
Base description of the runner.
Harold Barker's avatar
Harold Barker committed
36 37
Defaults to the hostname.

38 39
###### `gitlab_runner_executor`

Harold Barker's avatar
Harold Barker committed
40
The executor used by the runner.
Harold Barker's avatar
Harold Barker committed
41
Defaults to `shell`.
Harold Barker's avatar
Harold Barker committed
42

43 44
###### `gitlab_runner_concurrent_specific`

45 46 47
The maximum number of jobs to run concurrently on this specific runner.
Defaults to 0, simply means don't limit.

48 49
###### `gitlab_runner_docker_image`

50 51
The default Docker image to use. Required when executor is `docker`.

52 53 54
###### `gitlab_runner_tags`

Default tags assigned to the runner,
Harold Barker's avatar
Harold Barker committed
55
Defaults to an empty list.
Harold Barker's avatar
Harold Barker committed
56

Erick Hitter's avatar
Erick Hitter committed
57 58 59 60 61 62 63 64
###### `gitlab_runner_machine_idle_nodes`

How many idle machines to maintain. Defaults to `0`, meaning all hosts are created on-demand then culled after `gitlab_runner_machine_idle_time` minutes.

###### `gitlab_runner_machine_idle_time`

How long, in minutes, a machine can be idle before it's destroyed. Default is `3`.

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
###### `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`
Petr Shilo's avatar
Petr Shilo committed
87

88 89
See the [config for more options](https://github.com/riemers/ansible-gitlab-runner/blob/master/tasks/register-runner.yml)

Harold Barker's avatar
Harold Barker committed
90 91
Example Playbook
----------------
Harold Barker's avatar
Harold Barker committed
92 93 94 95 96 97
```yaml
- hosts: all
  remote_user: root
  vars_files:
    - vars/main.yml
  roles:
98
    - { role: riemers.gitlab-runner }
Harold Barker's avatar
Harold Barker committed
99 100 101 102 103 104 105 106 107 108
```

Inside `vars/main.yml`
```yaml
gitlab_runner_registration_token: 'HUzTMgnxk17YV8Rj8ucQ'
gitlab_runner_description: 'Example GitLab Runner'
gitlab_runner_tags:
  - node
  - ruby
  - mysql
109 110 111
gitlab_runner_docker_volumes:
  - "/var/run/docker.sock:/var/run/docker.sock"
  - "/cache"
Harold Barker's avatar
Harold Barker committed
112
```