zuul-jobs/roles/upload-logs/tasks/main.yaml
Paul Belanger 550e5da4b4 Allow upload-logs to toggle compression of console logs
We should make it easy for users to view console logs by default.
Today, we compress and upload logs and by default apache / nginx will
not properly display them as plain text.  This commit changes the
default to not compress, but allows more advanced users to enable this
logic.  As mostly likley it also means additional configuration for
your web server.

Change-Id: Ic446db4f85e2098db8fa4568f8c5140ba564e931
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2019-09-20 17:03:58 +00:00

72 lines
2.3 KiB
YAML

- name: Set zuul-log-path fact
include_role:
name: set-zuul-log-path-fact
# Always upload (true), never upload (false) or only on failure ('failure')
- when: zuul_site_upload_logs | default(true) | bool or
(zuul_site_upload_logs == 'failure' and not zuul_success | bool)
block:
- name: Create log directories
file:
path: "{{ zuul_logserver_root }}/{{ zuul_log_path }}"
state: directory
recurse: yes
mode: 0775
# Use chmod instead of file because ansible 2.5 file with recurse and
# follow can't really handle symlinks to .
- name: Ensure logs are readable before uploading
delegate_to: localhost
command: "chmod -R u=rwX,g=rX,o=rX {{ zuul.executor.log_root }}/"
# ANSIBLE0007 chmod used in place of argument mode to file
tags:
- skip_ansible_lint
- name: Upload logs to log server
synchronize:
src: "{{ zuul.executor.log_root }}/"
dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/"
rsync_opts:
- "--exclude=job-output.txt"
- "--exclude=job-output.json"
no_log: "{{ not zuul_log_verbose }}"
# After this point there are no more logs
- name: gzip console log and json output
delegate_to: localhost
archive:
path: "{{ zuul.executor.log_root }}/{{ item }}"
with_items:
- job-output.txt
- job-output.json
when: zuul_log_compress | bool
- name: Upload compressed console log and json output
synchronize:
src: "{{ zuul.executor.log_root }}/{{ item }}.gz"
dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/{{ item }}.gz"
verify_host: true
with_items:
- job-output.txt
- job-output.json
when: zuul_log_compress | bool
- name: Upload console log and json output
synchronize:
src: "{{ zuul.executor.log_root }}/{{ item }}"
dest: "{{ zuul_logserver_root }}/{{ zuul_log_path }}/{{ item }}"
verify_host: true
with_items:
- job-output.txt
- job-output.json
when: not zuul_log_compress | bool
- name: Return log URL to Zuul
delegate_to: localhost
zuul_return:
data:
zuul:
log_url: "{{ zuul_log_url }}/{{ zuul_log_path }}/"
when: zuul_log_url is defined