From 6910847bceed4054d037eb317494654f1b2f12c3 Mon Sep 17 00:00:00 2001 From: Gaudenz Steinlin Date: Wed, 15 Jun 2016 14:55:26 +0200 Subject: [PATCH] Fix config generated for rsyslog_client_log_files The rsyslog_client_log_files role variable was masked by the rsyslog_client_log_files fact set during the post install task. This caused the log files set in the rsyslog_client_log_files variable to be ignored on the second or later invocation of the rsyslog_client role. Instead the log files discovered from rsyslog_client_dir on previous runs of the role were add to the list of logfiles. This resulted in missing rsyslog configurations and duplicate logrotate entries. Change-Id: I00a58def426a4f30f1e64a24320ee68157b95f24 --- tasks/rsyslog_client_post_install.yml | 7 +++---- templates/99-rsyslog.conf.j2 | 2 +- templates/os_aggregate_storage.j2 | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tasks/rsyslog_client_post_install.yml b/tasks/rsyslog_client_post_install.yml index 4bef9bd..1668bdb 100644 --- a/tasks/rsyslog_client_post_install.yml +++ b/tasks/rsyslog_client_post_install.yml @@ -50,8 +50,7 @@ - name: Union the log files set_fact: - rsyslog_client_log_files: "{{ log_files.stdout_lines | union(rsyslog_client_log_files) }}" - when: log_files.stdout_lines is defined + rsyslog_client_all_log_files: "{{ log_files.stdout_lines | default([]) | union(rsyslog_client_log_files) }}" tags: - rsyslog-client-config @@ -61,7 +60,7 @@ dest: "/etc/rsyslog.d/{{ rsyslog_client_config_name }}" owner: "root" group: "root" - when: (rsyslog_client_log_files | length) > 0 + when: (rsyslog_client_all_log_files | length) > 0 tags: - rsyslog-client-config @@ -71,7 +70,7 @@ dest: "/etc/logrotate.d/{{ rsyslog_client_log_rotate_file }}" owner: "root" group: "root" - when: (rsyslog_client_log_files | length) > 0 + when: (rsyslog_client_all_log_files | length) > 0 tags: - rsyslog-client-config diff --git a/templates/99-rsyslog.conf.j2 b/templates/99-rsyslog.conf.j2 index 6e46b84..f1b1f3e 100644 --- a/templates/99-rsyslog.conf.j2 +++ b/templates/99-rsyslog.conf.j2 @@ -45,7 +45,7 @@ $ActionResumeRetryCount 250 {% endif %} # Log files -{% for log_file in rsyslog_client_log_files %} +{% for log_file in rsyslog_client_all_log_files %} $InputFileName {{ log_file }} $InputFileTag {{ log_file.split('.log')[0] | basename }}: $InputFileStateFile state-{{ log_file.split('.log')[0] | basename }} diff --git a/templates/os_aggregate_storage.j2 b/templates/os_aggregate_storage.j2 index a6f9ed4..81a6b08 100644 --- a/templates/os_aggregate_storage.j2 +++ b/templates/os_aggregate_storage.j2 @@ -1,4 +1,4 @@ -{% for log_file in rsyslog_client_log_files %} +{% for log_file in rsyslog_client_all_log_files %} {{ log_file }} {% endfor %} {