Skip to content

Commit

Permalink
Merge pull request #152 from 0xQSL/reload_runner
Browse files Browse the repository at this point in the history
Support systemd reloading on debian too
  • Loading branch information
riemers authored Dec 10, 2020
2 parents dfea5a4 + 4e2c19c commit eeb8d39
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 31 deletions.
3 changes: 3 additions & 0 deletions tasks/install-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@
path: /home/gitlab-runner/.bash_logout
state: absent
when: ansible_distribution_release in ["buster", "focal"]

- name: Set systemd reload options
import_tasks: systemd-reload.yml
33 changes: 2 additions & 31 deletions tasks/install-redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,5 @@
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
- name: Set systemd reload options
import_tasks: systemd-reload.yml
33 changes: 33 additions & 0 deletions tasks/systemd-reload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---

- 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/Debian.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: 720

0 comments on commit eeb8d39

Please sign in to comment.