Skip to content

Commit

Permalink
Merge pull request #151 from chancez/reload_runner
Browse files Browse the repository at this point in the history
Support reloading gitlab under systemd instead of restarting
  • Loading branch information
riemers authored Nov 30, 2020
2 parents 2d1cd2b + 550922b commit e981aa1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# non macOS
- name: restart_gitlab_runner
service: name=gitlab-runner state=restarted
service: name=gitlab-runner state={{ gitlab_runner_restart_state }}
become: yes
when: ansible_os_family != 'Darwin' and ansible_os_family != 'Windows' and not gitlab_runner_container_install

Expand All @@ -19,7 +19,7 @@

# Container
- name: restart_gitlab_runner_container
docker_container:
docker_container:
name: "{{ gitlab_runner_container_name }}"
restart: yes
when: gitlab_runner_container_install
32 changes: 32 additions & 0 deletions tasks/install-redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,35 @@
name: "{{ gitlab_runner_package }}"
state: "{{ gitlab_runner_package_state }}"
become: true

- name: Ensure /etc/systemd/system/gitlab-runner.service.d/ exists
file:
path: /etc/systemd/system/gitlab-runner.service.d
state: directory
owner: root
group: root
mode: 0755

- name: Add reload command to GitLab Runner system service
copy:
dest: /etc/systemd/system/gitlab-runner.service.d/exec-reload.conf
content: |
[Service]
ExecReload=/bin/kill -HUP $MAINPID
register: gitlab_runner_exec_reload

# https://docs.gitlab.com/runner/configuration/init.html#overriding-systemd
- name: Configure graceful stop for GitLab Runner system service
copy:
dest: /etc/systemd/system/gitlab-runner.service.d/kill.conf
content: |
[Service]
TimeoutStopSec={{ gitlab_runner_timeout_stop_seconds }}
KillSignal=SIGQUIT
when: gitlab_runner_timeout_stop_seconds > 0
register: gitlab_runner_kill_timeout

- name: Force systemd to reread configs
systemd:
daemon_reload: yes
when: gitlab_runner_exec_reload.changed or gitlab_runner_kill_timeout
2 changes: 2 additions & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ gitlab_runner_executable: "/usr/bin/{{ gitlab_runner_package_name }}"

gitlab_runner_runtime_owner: gitlab-runner
gitlab_runner_runtime_group: gitlab-runner
gitlab_runner_restart_state: reloaded
gitlab_runner_timeout_stop_seconds: 7200
1 change: 1 addition & 0 deletions vars/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ gitlab_runner_container_install: false
gitlab_runner_container_image: gitlab/gitlab-runner
gitlab_runner_container_tag: latest
gitlab_runner_container_name: gitlab-runner
gitlab_runner_restart_state: restarted

0 comments on commit e981aa1

Please sign in to comment.