Allow ara-report to run on any node

This role had some assumptions that it would run only on the
zuul-executor.  If we remove those assumptions, it can run on any
worker node, which allows it to be used in untrusted playbooks.

Note that this is backwards compatible only in the case that the
user did not provide a non-default value for ara_report_path.  If
a user overrode that (eg, to put the report in a directory other
than "ara" under the executor log dir), this will break.

Change-Id: I3a28368a049fa583398ece8a66f90783f53098f4
This commit is contained in:
James E. Blair 2020-07-24 11:50:38 -07:00 committed by James E. Blair
parent fcf84346ef
commit c24c09e82c
3 changed files with 7 additions and 14 deletions

View File

@ -51,9 +51,7 @@ If ARA is enabled, generates a report or saves a copy of the ARA database.
.. _mimetypes: https://opendev.org/opendev/puppet-openstackci/src/commit/5fe1f3d2d5e40c2458721e7dcf8631d62ea2525f/templates/logs.vhost.erb#L24
.. zuul:rolevar:: ara_report_path
:default: ``ara``
This path is relative to the root of the log directory.
:default: ``{{ zuul.executor.log_root }}/ara``
When report_type is 'html' directory where the HTML report will be generated.
When report_type is 'database', directory where the database is saved.

View File

@ -19,8 +19,7 @@ ara_report_type: 'html'
# Note that when using 'database', an ARA web application can load the database
# dynamically. See the ARA documentation for details:
# https://ara.readthedocs.io/en/latest/advanced.html#serving-ara-sqlite-databases-over-http
# This path is relative to the root of the log directory.
ara_report_path: 'ara'
ara_report_path: '{{ zuul.executor.log_root }}/ara'
# When report_type is 'html', whether to compress the ARA HTML output or not
ara_compress_html: true

View File

@ -7,7 +7,7 @@
- name: Warn if ARA is not installed
debug:
msg: |
ARA is not installed on the executor node, no report will be available.
ARA is not installed, no report will be available.
when: ara_installed.rc != 0
- name: Check that the ARA database exists
@ -36,10 +36,6 @@
It is likely that no report will be available, please verify the
execution and the parameters of the role for details.
- name: Prefix the log path with the log root
set_fact:
final_ara_report_path: "{{ zuul.executor.log_root }}/{{ ara_report_path }}"
- when:
- ara_installed.rc == 0
- ara_db.stat.exists
@ -48,7 +44,7 @@
# Always generate (true), never (false) or only on failure ('failure')
# Additionally cover for edge cases where zuul_success might be undefined
- name: Generate ARA HTML output
command: "{{ ara_report_executable }} generate html {{ final_ara_report_path }}"
command: "{{ ara_report_executable }} generate html {{ ara_report_path }}"
environment:
ARA_DATABASE: "sqlite:///{{ ara_database_path }}"
when: ara_report_run | bool or
@ -56,7 +52,7 @@
register: ara_generated
- name: Compress ARA HTML output
command: gzip --recursive --best {{ final_ara_report_path }}
command: gzip --recursive --best {{ ara_report_path }}
when:
- ara_compress_html | bool
- not ara_generated is skipped
@ -83,11 +79,11 @@
block:
- name: Create the ARA database report directory
file:
path: "{{ final_ara_report_path }}"
path: "{{ ara_report_path }}"
state: directory
- name: Save the ARA database
command: cp {{ ara_database_path }} {{ final_ara_report_path }}
command: cp {{ ara_database_path }} {{ ara_report_path }}
- name: Return ARA report
zuul_return:
data: