From 9ddfaa1d3487ecf640b4b9e71ee59f0a47561e85 Mon Sep 17 00:00:00 2001 From: Donien <88634789+Donien@users.noreply.github.com> Date: Thu, 4 Jul 2024 10:07:29 +0200 Subject: [PATCH] Add tasks to create icingadb-redis log directory Icinga's packages no longer create /var/log/icingadb-redis/ since logging moved to the journal by default. If logging to a file is needed, the according directory has to be created beforehand. Fixes #298 --- changelogs/fragments/fix_issue_298.yml | 3 +++ roles/icingadb_redis/tasks/install_on_debian.yml | 10 ++++++++++ roles/icingadb_redis/tasks/install_on_redhat.yml | 10 ++++++++++ roles/icingadb_redis/tasks/install_on_suse.yml | 10 ++++++++++ roles/icingadb_redis/templates/icingadb-redis.conf.j2 | 2 +- 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/fix_issue_298.yml diff --git a/changelogs/fragments/fix_issue_298.yml b/changelogs/fragments/fix_issue_298.yml new file mode 100644 index 00000000..547e9ab3 --- /dev/null +++ b/changelogs/fragments/fix_issue_298.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - Icinga's packages no longer create '/var/log/icingadb-redis/'. Added tasks that create a log directory based on `icingadb_redis_logfile` (#298). diff --git a/roles/icingadb_redis/tasks/install_on_debian.yml b/roles/icingadb_redis/tasks/install_on_debian.yml index c9ee7657..208beb53 100644 --- a/roles/icingadb_redis/tasks/install_on_debian.yml +++ b/roles/icingadb_redis/tasks/install_on_debian.yml @@ -4,3 +4,13 @@ name: "{{ item }}" state: present loop: "{{ icingadb_redis_packages }}" + +- name: Debian - Ensure log directory exists + when: + - icingadb_redis_logfile != "" + ansible.builtin.file: + path: "{{ icingadb_redis_logfile | dirname }}" + state: directory + owner: "{{ icingadb_redis_user }}" + group: "adm" + mode: "2750" diff --git a/roles/icingadb_redis/tasks/install_on_redhat.yml b/roles/icingadb_redis/tasks/install_on_redhat.yml index 9e25288d..a4205152 100644 --- a/roles/icingadb_redis/tasks/install_on_redhat.yml +++ b/roles/icingadb_redis/tasks/install_on_redhat.yml @@ -4,3 +4,13 @@ name: "{{ item }}" state: present loop: "{{ icingadb_redis_packages }}" + +- name: RedHat - Ensure log directory exists + when: + - icingadb_redis_logfile != "" + ansible.builtin.file: + path: "{{ icingadb_redis_logfile | dirname }}" + state: directory + owner: "{{ icingadb_redis_user }}" + group: "{{ icingadb_redis_user }}" + mode: "0750" diff --git a/roles/icingadb_redis/tasks/install_on_suse.yml b/roles/icingadb_redis/tasks/install_on_suse.yml index d40ff048..4c15382d 100644 --- a/roles/icingadb_redis/tasks/install_on_suse.yml +++ b/roles/icingadb_redis/tasks/install_on_suse.yml @@ -3,3 +3,13 @@ community.general.zypper: name: "{{ icingadb_redis_packages }}" state: present + +- name: Suse - Ensure log directory exists + when: + - icingadb_redis_logfile != "" + ansible.builtin.file: + path: "{{ icingadb_redis_logfile | dirname }}" + state: directory + owner: "{{ icingadb_redis_user }}" + group: "{{ icingadb_redis_user }}" + mode: "0750" diff --git a/roles/icingadb_redis/templates/icingadb-redis.conf.j2 b/roles/icingadb_redis/templates/icingadb-redis.conf.j2 index a531bc9e..8e018215 100644 --- a/roles/icingadb_redis/templates/icingadb-redis.conf.j2 +++ b/roles/icingadb_redis/templates/icingadb-redis.conf.j2 @@ -13,7 +13,7 @@ tcp-keepalive {{ icingadb_redis_tcp_keepalive }} supervised {{ icingadb_redis_supervised }} pidfile {{ icingadb_redis_pidfile }} loglevel {{ icingadb_redis_loglevel }} -logfile {{ icingadb_redis_logfile }} +logfile "{{ icingadb_redis_logfile }}" # syslog-enabled no # syslog-ident redis # syslog-facility local0