James E. Blair feaf0f2ad5 Support the project argument in GCS
The Google credential object now requires that the project be supplied,
so plumb that through in the GCS log upload role.

Change-Id: I4519fbcb9ac7b8bbd34ab7f17aada3e50c1aaa4b
2020-11-12 10:00:23 -08:00

39 lines
1.3 KiB
YAML

- name: Set zuul-log-path fact
include_role:
name: set-zuul-log-path-fact
when: zuul_log_path is not defined
# 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 Google Cloud Storage
delegate_to: localhost
zuul_google_storage_upload:
partition: "{{ zuul_log_partition }}"
container: "{{ zuul_log_container }}"
prefix: "{{ zuul_log_path }}"
indexes: "{{ zuul_log_create_indexes }}"
credentials_file: "{{ zuul_log_credentials_file }}"
project: "{{ zuul_log_project }}"
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