From a5e65fc6fcc87b34a99dcab8381678832f5bb76f Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Wed, 25 Jan 2017 22:26:20 +0200 Subject: [PATCH] Support exclude list for logs collecting Sometimes we want to collect everything, but specific files and folders. Support exclude list for this. Change-Id: I10302ee50c5539fbacd539371dde0e7d0d7c4f71 --- roles/collect-logs/README.md | 3 +++ roles/collect-logs/defaults/main.yml | 8 +++++++- roles/collect-logs/tasks/collect.yml | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/roles/collect-logs/README.md b/roles/collect-logs/README.md index 1248b9354..1ad94026c 100644 --- a/roles/collect-logs/README.md +++ b/roles/collect-logs/README.md @@ -34,6 +34,9 @@ artcl_collect_list: - /home/stack/*.log - /var/log ``` +* `artcl_exclude_list` -- A list of files and directories to remove from + the collected logs. First of all we collect everything and then remove all + we have in `artcl_exclude_list` (`/etc/puppet/modules` by default). * `artcl_collect_dir` -- A local directory where the logs should be gathered, without a trailing slash. diff --git a/roles/collect-logs/defaults/main.yml b/roles/collect-logs/defaults/main.yml index 51f443dac..6717ab79c 100644 --- a/roles/collect-logs/defaults/main.yml +++ b/roles/collect-logs/defaults/main.yml @@ -3,7 +3,6 @@ artcl_collect: true artcl_collect_list: - /var/log/ - - /var/lib/mysql - /var/lib/heat-config/heat-config-puppet/ - /var/lib/heat-config/heat-config-script/ - /var/tmp/sosreport* @@ -31,6 +30,13 @@ artcl_collect_list: - /home/stack/browbeat/results - /usr/share/openstack-tripleo-heat-templates - /tmp/tripleoclient* +artcl_exclude_list: + - /etc/udev/hwdb.bin + - /etc/puppet/modules + - /etc/project-config + - /etc/services + - /etc/selinux/targeted + - /etc/pki/ca-trust/extracted artcl_collect_dir: "{{ local_working_dir }}/collected_files" artcl_gzip_only: true artcl_tar_gz: false diff --git a/roles/collect-logs/tasks/collect.yml b/roles/collect-logs/tasks/collect.yml index e9527d487..06d5a8574 100644 --- a/roles/collect-logs/tasks/collect.yml +++ b/roles/collect-logs/tasks/collect.yml @@ -188,6 +188,9 @@ cp -rL --parents $F /tmp/{{ inventory_hostname }}; done; find /tmp/{{ inventory_hostname }} -not -type f -not -type d -delete; + for D in {{ artcl_exclude_list | default([]) | join(' ') }}; do + rm -rf "/tmp/{{ inventory_hostname }}/$D"; + done; find /tmp/{{ inventory_hostname }} -type d -print0 | xargs -0 chmod 755; find /tmp/{{ inventory_hostname }} -type f -print0 | xargs -0 chmod 644; chown -R {{ ansible_user }}: /tmp/{{ inventory_hostname }};