magnum/playbooks/container-builder-copy-logs...

47 lines
1.9 KiB
YAML

- hosts: all
tasks:
- shell:
cmd: |
set +o errexit
mkdir -p logs
# copy system log
sudo cp -r /var/log logs/system_log
if which journalctl ; then
# the journal gives us syslog() and kernel output, so is like
# a concatenation of the above.
sudo journalctl --no-pager | sudo tee logs/syslog.txt > /dev/null
sudo journalctl --no-pager -u docker.service | sudo tee logs/docker.log > /dev/null
fi
# sudo config
# final memory usage and process list
ps -eo user,pid,ppid,lwp,%cpu,%mem,size,rss,cmd > logs/ps.txt
# docker related information
(docker info && docker system df && docker system df -v) > logs/docker-info.txt
# fix the permissions for logs folder
sudo chmod -R 777 logs
# rename files to .txt; this is so that when displayed via
# logs.openstack.org clicking results in the browser shows the
# files, rather than trying to send it to another app or make you
# download it, etc.
# firstly, rename all .log files to .txt files
for f in $(find logs -name "*.log"); do
sudo mv $f ${f/.log/.txt}
done
# Update symlinks to new file names
for f in $(find logs -name "*FAILED*"); do
sudo mv ${f} ${f}.gz
sudo ln -sf ${f#*/000_FAILED_}.gz ${f}.gz
done
# Compress all text logs
find logs -iname '*.txt' -execdir gzip -9 {} \+
find logs -iname '*.json' -execdir gzip -9 {} \+
executable: /bin/bash
chdir: "{{ zuul.project.src_dir }}"
- synchronize:
src: '{{ zuul.project.src_dir }}/logs'
dest: '{{ zuul.executor.log_root }}'
mode: pull
copy_links: true
verify_host: true