From 4ebf9a4e14b7a030469f7fc467749d168d098787 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Wed, 28 Dec 2022 18:14:57 +0100 Subject: [PATCH] Use multiple logcheck ignore files --- system/base/logs/meta/argument_specs.yml | 2 +- system/base/logs/tasks/main.yml | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/system/base/logs/meta/argument_specs.yml b/system/base/logs/meta/argument_specs.yml index 51334d6..5e227b1 100644 --- a/system/base/logs/meta/argument_specs.yml +++ b/system/base/logs/meta/argument_specs.yml @@ -5,6 +5,6 @@ argument_specs: ansible_hostname: type: "str" required: true - system_base_logs_ignore_file: + system_base_logs_ignore_dir: type: "str" required: false diff --git a/system/base/logs/tasks/main.yml b/system/base/logs/tasks/main.yml index 29a1103..35dc3c1 100644 --- a/system/base/logs/tasks/main.yml +++ b/system/base/logs/tasks/main.yml @@ -11,9 +11,21 @@ dest: "/etc/logcheck/logcheck.conf" mode: 0640 -- name: "logs : configure logcheck ignores" - ansible.builtin.copy: - src: "{{ system_base_logs_ignore_file }}" - dest: "/etc/logcheck/ignore.d.server/{{ ansible_hostname }}" - group: "logcheck" - mode: 0644 +- block: + + - name: "identify logcheck ignore files" + local_action: stat path="{{ system_base_logs_ignore_dir }}/{{ item }}" + register: system_base_logs_ignore_files_stat + loop: "{{ [ansible_hostname, 'all'] | union(group_names) }}" + + - name: "configure logcheck ignores" + ansible.builtin.copy: + src: "{{ system_base_logs_ignore_dir }}/{{ item }}" + dest: "/etc/logcheck/ignore.d.server/{{ item }}" + group: "logcheck" + mode: 0644 + loop: "{{ system_base_logs_ignore_files_stat.results | selectattr('stat.exists') | + map(attribute='item') }}" + + when: + system_base_logs_ignore_dir is defined