From 14bcd20a41f5e082b1ecba40a21ab5a09f609838 Mon Sep 17 00:00:00 2001 From: Devan Carpenter Date: Fri, 6 Nov 2020 00:31:16 +0100 Subject: [PATCH] split KVM and docker configs Config cannot have conflicting executor configurations. One _must_ specify the selected executor in a sub-section. eg. "[runners.docker]", otherwise you end up with mysterious errors like: WARNING: Job failed: panic: runtime error: invalid memory address or nil pointer dereference --- roles/gitlab-runner/tasks/main.yml | 11 +++++++++-- .../templates/gitlab-runner-docker.toml | 18 ++++++++++++++++++ ...tlab-runner.toml => gitlab-runner-kvm.toml} | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 roles/gitlab-runner/templates/gitlab-runner-docker.toml rename roles/gitlab-runner/templates/{gitlab-runner.toml => gitlab-runner-kvm.toml} (97%) diff --git a/roles/gitlab-runner/tasks/main.yml b/roles/gitlab-runner/tasks/main.yml index 3dde187..ded7f35 100644 --- a/roles/gitlab-runner/tasks/main.yml +++ b/roles/gitlab-runner/tasks/main.yml @@ -55,10 +55,17 @@ with_items: [config, prepare, run, cleanup] when: ansible_local.gitlab_runner.executor == "kvm" -- name: Install configuration for the gitlab runner +- name: Install KVM configuration for the gitlab runner template: - src: gitlab-runner.toml + src: gitlab-runner-kvm.toml dest: /etc/gitlab-runner/config.toml + when: ansible_local.gitlab_runner.executor == "kvm" + +- name: Install Docker configuration for the gitlab runner + template: + src: gitlab-runner-docker.toml + dest: /etc/gitlab-runner/config.toml + when: ansible_local.gitlab_runner.executor == "docker" - name: Put gitlab-runner in the docker group user: diff --git a/roles/gitlab-runner/templates/gitlab-runner-docker.toml b/roles/gitlab-runner/templates/gitlab-runner-docker.toml new file mode 100644 index 0000000..13efca3 --- /dev/null +++ b/roles/gitlab-runner/templates/gitlab-runner-docker.toml @@ -0,0 +1,18 @@ +concurrent = 5 +check_interval = 0 +log_level = "info" + +[session_server] + session_timeout = 1800 + +[[runners]] + name = "{{ ansible_fqdn }}" + url = "https://{{ ansible_local.gitlab_runner.gitlab_domain }}" + token = "{{ ansible_local.gitlab_runner.runner_token }}" + executor = "{{ ansible_local.gitlab_runner.executor }}" + + [runners.docker] + image = "debian:stable" + privileged = false + disable_cache = false + shm_size = 0 diff --git a/roles/gitlab-runner/templates/gitlab-runner.toml b/roles/gitlab-runner/templates/gitlab-runner-kvm.toml similarity index 97% rename from roles/gitlab-runner/templates/gitlab-runner.toml rename to roles/gitlab-runner/templates/gitlab-runner-kvm.toml index 271b765..8f4fe20 100644 --- a/roles/gitlab-runner/templates/gitlab-runner.toml +++ b/roles/gitlab-runner/templates/gitlab-runner-kvm.toml @@ -1,5 +1,6 @@ concurrent = 5 check_interval = 0 +log_level = "info" [session_server] session_timeout = 1800