Merge "Add modified upload-logs as test-upload-logs to base-test"
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
- hosts: "{{ site_logs.fqdn }}"
|
- hosts: "{{ site_logs.fqdn }}"
|
||||||
gather_facts: False
|
gather_facts: False
|
||||||
roles:
|
roles:
|
||||||
- role: upload-logs
|
- role: test-upload-logs
|
||||||
zuul_log_url: "http://logs.openstack.org"
|
zuul_log_url: "http://logs.openstack.org"
|
||||||
|
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
|
23
roles/test-upload-logs/README.rst
Normal file
23
roles/test-upload-logs/README.rst
Normal 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.
|
58
roles/test-upload-logs/tasks/main.yaml
Normal file
58
roles/test-upload-logs/tasks/main.yaml
Normal 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
|
1
roles/test-upload-logs/vars/main.yaml
Normal file
1
roles/test-upload-logs/vars/main.yaml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
zuul_logserver_root: /srv/static/logs
|
Reference in New Issue
Block a user