From 7ea009d7a4992bcca441e9576611396de36668a9 Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Sat, 30 Jan 2021 20:16:49 +0100 Subject: [PATCH] gitlab: Add option to use a tmpfs instead of log bindmount This patch will provide a new config option `gitlab_log_tmpfs` to configure the docker container to setup a tmpfs instead of the bindmount for the log directory of GitLab. This should solve all headache around logs clogging up the disk but might just trades it against memory problems. So far the test-run looks good, but time will tell if it is a sufficent solution. --- roles/gitlab/defaults/main.yml | 3 +++ roles/gitlab/templates/docker-compose.yml | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/roles/gitlab/defaults/main.yml b/roles/gitlab/defaults/main.yml index c4fcecf..ad117a6 100644 --- a/roles/gitlab/defaults/main.yml +++ b/roles/gitlab/defaults/main.yml @@ -24,6 +24,9 @@ gitlab_data_location: "{{ gitlab_install_location }}/data" gitlab_config_location: "{{ gitlab_install_location }}/config" gitlab_log_location: "{{ gitlab_install_location }}/log" +# Put GitLab's logs in a tempfs instead to save headache with diskspace +gitlab_log_tmpfs: false + # Set the certresolver to your desired traefik certresolver. # Note: This is `letsencrypt_cf` by default for backwards compatibility, you might want to use `letsencrypt_http` instead, depending on your setup gitlab_traefik_certresolver: letsencrypt_http diff --git a/roles/gitlab/templates/docker-compose.yml b/roles/gitlab/templates/docker-compose.yml index cb77a14..e61988b 100644 --- a/roles/gitlab/templates/docker-compose.yml +++ b/roles/gitlab/templates/docker-compose.yml @@ -203,7 +203,16 @@ services: volumes: - "{{ gitlab_data_location }}:/var/opt/gitlab" - "{{ gitlab_config_location }}:/etc/gitlab" +{% if gitlab_log_tmpfs %} - "{{ gitlab_log_location }}:/var/log/gitlab" +{% endif %} + + +{% if gitlab_log_tmpfs %} + tmpfs: + - "/var/log/gitlab:size=1G,noexec,nodev,nosuid,rw" +{% endif %} + restart: always ports: - "{{ gitlab_ssh_port }}:22"