Skip to content

Commit

Permalink
multiple runner at once
Browse files Browse the repository at this point in the history
  • Loading branch information
László Szalma committed Dec 13, 2016
1 parent 1113e19 commit 25c40e3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ The default Docker image to use. Required when executor is `docker`.
The tags assigned to the runner,
Defaults to an empty list.

See the [config for more options](https://github.com/riemers/ansible-gitlab-runner/blob/master/tasks/register-runner.yml)
`gitlab_runner_list`
You can add multiple runners in one run. It is a list of dict based on the settings available in one runner. You must set different descriptions for the runners to work.

# NOTE:
Runners are created for the first time. You can't change the settings of existsing ones with this role.

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

Example Playbook
----------------
Expand Down
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ gitlab_runner_ssh_host: ''
gitlab_runner_ssh_port: ''
gitlab_runner_ssh_password: ''
gitlab_runner_ssh_identity_file: ''

gitlab_runner_list:
- coordinator_url: 'https://gitlab.com/ci'
registration_token: ''
description: '{{ ansible_hostname }}'
executor: 'shell'
tags: []
1 change: 0 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@

- name: Register GitLab Runner
include: register-runner.yml
when: gitlab_runner_registration_token != ''
20 changes: 19 additions & 1 deletion tasks/register-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,22 @@
--ssh-port '{{gitlab_runner_ssh_port}}'
--ssh-password '{{gitlab_runner_ssh_password}}'
--ssh-identity-file '{{gitlab_runner_ssh_identity_file}}'
when: configured_runners.stderr.find('\n{{ gitlab_runner_description }}') == -1
when: gitlab_runner_registration_token != '' and configured_runners.stderr.find('\n{{ gitlab_runner_description }}') == -1

- name: Register multiple runner to GitLab
command: gitlab-runner register >
--non-interactive
--url '{{ item.coordinator_url | d("https://gitlab.com/ci") }}'
--registration-token '{{ item.registration_token }}'
--description '{{ item.description }}'
--tag-list '{{ item.tags | d([]) | join(",") }}'
--executor '{{ item.executor | d("shell") }}'
--docker-image '{{ item.docker_image | d("") }}'
--docker-volumes [ "{{ item.docker_volumes | d([]) | join('", "') }}" ]
--ssh-user '{{ item.ssh_user | d("") }}'
--ssh-host '{{ item.ssh_host | d("") }}'
--ssh-port '{{ item.ssh_port | d("") }}'
--ssh-password '{{ item.ssh_password | d("") }}'
--ssh-identity-file '{{ item.identity_file | d("") }}'
when: configured_runners.stderr.find('\n{{ item.description }}') == -1
with_items: "{{ gitlab_runner_list }}"

0 comments on commit 25c40e3

Please sign in to comment.