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
This commit is contained in:
Sagi Shnaidman 2017-01-25 22:26:20 +02:00
parent 39c3e4a7fd
commit a5e65fc6fc
3 changed files with 13 additions and 1 deletions

View File

@ -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.

View File

@ -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

View File

@ -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 }};