zuul-jobs/roles/wip-upload-logs-swift/tasks/main.yaml
James E. Blair 2bf16a421f Add upload-logs-swift role
This adds a role to upload log files to swift.  It generates index
files, sets expiration times, and creates partitioned containers as
needed.

This is largely based on the zuul_swift_upload.py script written for
Zuul v2 by Joshua Hesketh.

Change-Id: If520c849fe6a20833804609583ea758e8dd2a6f6
Co-Authored-By: Joshua Hesketh <josh@nitrotech.org>
2018-07-27 13:40:03 -07:00

40 lines
1.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:
# 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 swift
delegate_to: localhost
zuul_swift_upload:
cloud: "{{ zuul_log_cloud_config }}"
partition: "{{ zuul_log_partition }}"
container: "{{ zuul_log_container }}"
public: "{{ zuul_log_container_public }}"
prefix: "{{ zuul_log_path }}"
files:
- "{{ zuul.executor.log_root }}/"
register: upload_results
- name: Return log URL to Zuul
delegate_to: localhost
zuul_return:
data:
zuul:
log_url: "{{ upload_results.url }}"
when: upload_results is defined
tags:
# Avoid "no action detected in task" linter error
- skip_ansible_lint