From a8314f413ba4fab4835edf0dcb9f5db60f3f5cd1 Mon Sep 17 00:00:00 2001 From: Federico Ressi Date: Tue, 21 Dec 2021 19:03:17 +0100 Subject: [PATCH] Collect report files from docker jobs Change-Id: Id9e0690019e5aae42d58b0a27970c59b3443720f --- playbooks/docker/post.yaml | 5 +++ .../tobiko-collect-report/defaults/main.yaml | 7 ++++ roles/tobiko-collect-report/tasks/main.yaml | 42 +++++++++++++++++++ zuul.d/docker.yaml | 1 + 4 files changed, 55 insertions(+) create mode 100644 playbooks/docker/post.yaml create mode 100644 roles/tobiko-collect-report/defaults/main.yaml create mode 100644 roles/tobiko-collect-report/tasks/main.yaml diff --git a/playbooks/docker/post.yaml b/playbooks/docker/post.yaml new file mode 100644 index 000000000..d449260e2 --- /dev/null +++ b/playbooks/docker/post.yaml @@ -0,0 +1,5 @@ +--- + +- hosts: all + roles: + - role: tobiko-collect-report diff --git a/roles/tobiko-collect-report/defaults/main.yaml b/roles/tobiko-collect-report/defaults/main.yaml new file mode 100644 index 000000000..1b3fb95d7 --- /dev/null +++ b/roles/tobiko-collect-report/defaults/main.yaml @@ -0,0 +1,7 @@ +--- +tobiko_report_dir: "{{ zuul_work_dir }}/report" + +zuul_work_dir: "{{ zuul.project.src_dir }}" + +zuul_output_dir: "{{ ansible_user_dir }}/zuul-output" +zuul_use_fetch_output: "{{ zuul_site_use_fetch_output|default(false) }}" diff --git a/roles/tobiko-collect-report/tasks/main.yaml b/roles/tobiko-collect-report/tasks/main.yaml new file mode 100644 index 000000000..c61972e28 --- /dev/null +++ b/roles/tobiko-collect-report/tasks/main.yaml @@ -0,0 +1,42 @@ +--- + +- name: Set Tobiko log path for multiple nodes + set_fact: + log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/tobiko" + when: groups['all'] | length > 1 + +- name: Set Tobiko log path for single node + set_fact: + log_path: "{{ zuul.executor.log_root }}/tobiko" + when: log_path is not defined + +- name: Ensure local report dir + file: + path: "{{ log_path }}" + state: directory + mode: 0755 + delegate_to: localhost + +- name: Ensure zuul-output report dir + file: + path: "{{ zuul_output_dir }}/logs/tobiko" + state: directory + mode: 0755 + when: zuul_use_fetch_output + +- name: Copy Tobiko logs # noqa risky-file-permissions + copy: + dest: "{{ zuul_output_dir }}/logs/tobiko/" + src: "{{ tobiko_report_dir }}/" + remote_src: true + when: zuul_use_fetch_output + +- name: Collect Tobiko logs + synchronize: + dest: "{{ log_path }}" + mode: pull + src: "{{ tobiko_report_dir }}/" + verify_host: true + owner: no + group: no + when: not zuul_use_fetch_output diff --git a/zuul.d/docker.yaml b/zuul.d/docker.yaml index c48405340..c416352fb 100644 --- a/zuul.d/docker.yaml +++ b/zuul.d/docker.yaml @@ -23,6 +23,7 @@ timeout: 2400 pre-run: playbooks/docker/pre.yaml run: playbooks/docker/run.yaml + post-run: playbooks/docker/post.yaml # post-run: playbooks/docker/post.yaml vars: docker_compose_service: unit