Skip to content

Commit

Permalink
Add support for Docker services
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelbrueckner committed Mar 5, 2022
1 parent 65853db commit 73ec1ee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
@@ -1,8 +1,7 @@
GitLab Runner [![Build Status](https://api.travis-ci.org/riemers/ansible-gitlab-runner.svg?branch=master)](https://travis-ci.org/riemers/ansible-gitlab-runner) [![Ansible Role](https://img.shields.io/badge/role-riemers.gitlab--runner-blue.svg?maxAge=2592000)](https://galaxy.ansible.com/riemers/gitlab-runner/)
=============

This role will install the [official GitLab Runner](https://gitlab.com/gitlab-org/gitlab-runner)
(fork from haroldb) with updates. Needed something simple and working, this did the trick for me. Open for changes though.
This role will install the [official GitLab Runner](https://gitlab.com/gitlab-org/gitlab-runner) with updates. This is a fork of [riemers.gitlab-runner](https://github.com/riemers/ansible-gitlab-runner) to add support for configuring Docker services.

Requirements
------------
Expand Down
11 changes: 11 additions & 0 deletions defaults/main.yml
Expand Up @@ -96,6 +96,17 @@ gitlab_runner_runners:
#
# Custom environment variables injected to build environment
env_vars: []
#
# Defines additional services. The default is to not run additional services.
# docker_services:
# - name: "registry.example.com/svc1"
# alias: "svc1"
# entrypoint: ["entrypoint-script.sh"]
# command: ["executable","param1","param2"]
# - name: docker:20.10.12-dind
# command: ["--insecure-registry=10.0.0.0/24"]
# - name: registry:2
#
# Sets the clone_url. The default is not set.
# clone_url:
#
Expand Down
13 changes: 13 additions & 0 deletions tasks/update-config-runner.yml
Expand Up @@ -318,6 +318,19 @@
- restart_gitlab_runner
- restart_gitlab_runner_macos

#### [[runners.docker.services]] section ####
- name: "{{ runn_name_prefix }} Set additional services"
blockinfile:
dest: "{{ temp_runner_config.path }}"
content: "{{ lookup('template', 'config.runners.docker.services.j2') if gitlab_runner.docker_services is defined }}"
state: "{{ 'present' if gitlab_runner.docker_services is defined else 'absent' }}"
marker: "# {mark} runners.docker.services"
insertafter: EOF
check_mode: no
notify:
- restart_gitlab_runner
- restart_gitlab_runner_macos

#### [runners.custom_build_dir] section #####
- name: "{{ runn_name_prefix }} Set custom_build_dir section"
lineinfile:
Expand Down
6 changes: 6 additions & 0 deletions templates/config.runners.docker.services.j2
@@ -0,0 +1,6 @@
{% for service in gitlab_runner.docker_services %}
[[runners.docker.services]]
{% for attr in service %}
{{ attr }} = {{ service[attr] | to_json }}
{% endfor %}
{% endfor %}

0 comments on commit 73ec1ee

Please sign in to comment.