From fcc707c2213bc10041f929b37baf0c3cafe2d05e Mon Sep 17 00:00:00 2001 From: David Moreau-Simard Date: Thu, 12 Oct 2017 12:57:12 -0400 Subject: [PATCH] Add a toggle to enable saving the ARA sqlite database It might be useful for jobs to save the ARA sqlite database, for example for debugging purposes, or if they want to import and use the database elsewhere. Change-Id: Ie82b42c34dfe6173116d88cc174deda70c5aa9ad --- roles/emit-ara-html/README.rst | 5 +++++ roles/emit-ara-html/defaults/main.yaml | 3 +++ roles/emit-ara-html/tasks/main.yaml | 10 +++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/roles/emit-ara-html/README.rst b/roles/emit-ara-html/README.rst index bca365610..83a389e66 100644 --- a/roles/emit-ara-html/README.rst +++ b/roles/emit-ara-html/README.rst @@ -12,6 +12,11 @@ Have ARA generate html logs if ARA and ARA data are both present. Whether to compress the ARA HTML output or not. Defaults to ``true``. +.. zuul:rolevar:: ara_save_database + + Whether the ARA sqlite database should be saved as part of the logs. + Defaults to ``false``. + .. tip:: Make sure the web server is configured to set the required mimetypes_ in order to serve gzipped content properly. diff --git a/roles/emit-ara-html/defaults/main.yaml b/roles/emit-ara-html/defaults/main.yaml index c95c8acdc..7fd6f4fe7 100644 --- a/roles/emit-ara-html/defaults/main.yaml +++ b/roles/emit-ara-html/defaults/main.yaml @@ -3,3 +3,6 @@ ara_generate_html: true # Whether to compress the ARA HTML output or not ara_compress_html: true + +# Whether to save the ARA sqlite database as part of the logs or not +ara_save_database: false diff --git a/roles/emit-ara-html/tasks/main.yaml b/roles/emit-ara-html/tasks/main.yaml index 34a71ad98..6a31393f8 100644 --- a/roles/emit-ara-html/tasks/main.yaml +++ b/roles/emit-ara-html/tasks/main.yaml @@ -3,6 +3,14 @@ path: "{{ zuul.executor.work_root }}/.ara/ansible.sqlite" register: ara_db_stat +- name: Save the ARA database + command: | + cp "{{ zuul.executor.work_root }}/.ara/ansible.sqlite" \ + {{ zuul.executor.log_root }} + when: + - ara_db_stat.stat.exists + - ara_save_database | bool + - name: Check for ARA install command: which ara ignore_errors: yes @@ -20,4 +28,4 @@ - name: Compress ARA html output command: gzip --recursive --best {{ zuul.executor.log_root }}/ara ignore_errors: yes - when: ara_compress_html | bool + when: ara_compress_html | bool \ No newline at end of file