Add modified upload-logs as test-upload-logs to base-test

Change-Id: I645727fb30de6abe325c694d04886711c205e620
This commit is contained in:
Monty Taylor 2018-01-25 14:45:57 -06:00
parent 0b142f8bcb
commit 068a754bad
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
4 changed files with 83 additions and 1 deletions

View File

@ -7,7 +7,7 @@
- hosts: "{{ site_logs.fqdn }}"
gather_facts: False
roles:
- role: upload-logs
- role: test-upload-logs
zuul_log_url: "http://logs.openstack.org"
- hosts: localhost

View File

@ -0,0 +1,23 @@
Upload logs to a static webserver
This uploads logs to a static webserver using SSH.
**Role Variables**
.. zuul:rolevar:: zuul_log_url
Base URL where logs are to be found.
.. zuul:rolevar:: zuul_logserver_root
:default: /srv/static/logs
The root path to the logs on the logserver.
.. zuul:rolevar:: zuul_site_upload_logs
:default: true
Controls when logs are uploaded. true, the default, means always upload
logs. false means never upload logs. 'failure' means to only upload logs
when the job has failed.
.. note:: Intended to be set by admins via site-variables.

View File

@ -0,0 +1,58 @@
- 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
- name: Ensure logs are readable before uploading
delegate_to: localhost
file:
path: "{{ zuul.executor.log_root }}/"
mode: u=rwX,g=rX,o=rX
state: directory
recurse: yes
- 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: true
# 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
- name: Upload 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
- 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

View File

@ -0,0 +1 @@
zuul_logserver_root: /srv/static/logs