From 86e9b70df97eaffe623a3df564b670aa4b3efdbd Mon Sep 17 00:00:00 2001 From: Daniel Pawlik Date: Tue, 6 Jun 2023 09:48:03 +0200 Subject: [PATCH] Set log_size_max size for podman logs Sometimes the logs can take over 20GB in few weeks. By setting 1GB as log_size_max should avoid situation that we are out of the disk few times per week. The feature has been added into the podman containers.conf file in podman 2.2.0 release [1], but on Centos 7, version is below 2.2.0. According to the libpod.conf man [2], that option should be also available in podman 1.6.4, but it is located in libpod.conf file. More info [3]. [1] https://github.com/containers/podman/releases/tag/v2.2.0 [2] https://manpages.debian.org/unstable/podman/libpod.conf.5.en.html [3] https://github.com/unifi-utilities/unifios-utilities/issues/100 Change-Id: Ic6d01e11606c9526d1880583876d76c4415250ac --- playbooks/site_rdo.yaml | 1 + playbooks/site_sf.yaml | 1 + roles/system/podman/defaults/main.yaml | 3 +++ roles/system/podman/tasks/main.yaml | 18 ++++++++++++++++++ 4 files changed, 23 insertions(+) create mode 100644 roles/system/podman/defaults/main.yaml create mode 100644 roles/system/podman/tasks/main.yaml diff --git a/playbooks/site_rdo.yaml b/playbooks/site_rdo.yaml index b098f9e3..86b84c7b 100644 --- a/playbooks/site_rdo.yaml +++ b/playbooks/site_rdo.yaml @@ -9,6 +9,7 @@ roles: - service/node-exporter - system/update-host + - system/podman - hosts: backup-rdo roles: diff --git a/playbooks/site_sf.yaml b/playbooks/site_sf.yaml index 775009d6..fc33772f 100644 --- a/playbooks/site_sf.yaml +++ b/playbooks/site_sf.yaml @@ -11,6 +11,7 @@ - infra/ssh - service/node-exporter - system/update-host + - system/podman - hosts: backup-sf roles: diff --git a/roles/system/podman/defaults/main.yaml b/roles/system/podman/defaults/main.yaml new file mode 100644 index 00000000..8a307936 --- /dev/null +++ b/roles/system/podman/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +# set 1000MB in bytes +log_size_max: 1048576000 diff --git a/roles/system/podman/tasks/main.yaml b/roles/system/podman/tasks/main.yaml new file mode 100644 index 00000000..0b919a07 --- /dev/null +++ b/roles/system/podman/tasks/main.yaml @@ -0,0 +1,18 @@ +--- +- name: Set max log limit - new way + become: true + ini_file: + path: /etc/containers/containers.conf + section: containers + option: log_size_max + value: "{{ log_size_max }}" + backup: true + +- name: Set max log limit - legacy + become: true + lineinfile: + path: /etc/containers/libpod.conf + regexp: "^max_log_size" + line: "max_log_size={{ log_size_max }}" + create: true + when: ansible_distribution_major_version|int < 8