diff --git a/README.md b/README.md index 956d7da07a89eba090e4de554b6388564cce46aa..574c58020dca83f62de5ced01e4f055b6ecd2759 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/defaults/main.yml b/defaults/main.yml index 951897ed08a31850ae7438d46c04245512d8b8b5..b88f84bdf38abffe0bd41a1d6cf047a05202a456 100644 --- a/defaults/main.yml +++ b/defaults/main.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' diff --git a/meta/main.yml b/meta/main.yml index 124a476eda263482acf7b365273d2322f4b438fc..4a51f437e282e525840ef9cdadb4905ef6c631b8 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,19 +1,13 @@ --- 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 diff --git a/tasks/register-runner.yml b/tasks/register-runner.yml index c44bf3f44b3fd6383788c5e99794946d662f2f8c..1ebf0087b1fa3f36bd5eedeffce69d74b382a358 100644 --- a/tasks/register-runner.yml +++ b/tasks/register-runner.yml @@ -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 diff --git a/templates/runner.repo.j2 b/templates/runner.repo.j2 deleted file mode 100644 index 97da48259a9cdd86dfdebd6bf8e90c7bff266e39..0000000000000000000000000000000000000000 --- a/templates/runner.repo.j2 +++ /dev/null @@ -1,19 +0,0 @@ -[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