From 4420bbd2c94ef8bae9bd3ec5139d67fe21d44243 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Thu, 3 Aug 2017 16:37:00 -0400 Subject: [PATCH] Create fetch-tox-output role We can move the content from tox/post.yaml into an ansible role. This allows other projects to use it. Change-Id: Ic7fc31a372de29a3a97ef84539faf3b0a1d6e181 Signed-off-by: Paul Belanger --- playbooks/tox/post.yaml | 35 ++--------------------- roles/fetch-tox-output/README.rst | 1 + roles/fetch-tox-output/defaults/main.yaml | 2 ++ roles/fetch-tox-output/tasks/main.yaml | 32 +++++++++++++++++++++ 4 files changed, 37 insertions(+), 33 deletions(-) create mode 100644 roles/fetch-tox-output/README.rst create mode 100644 roles/fetch-tox-output/defaults/main.yaml create mode 100644 roles/fetch-tox-output/tasks/main.yaml diff --git a/playbooks/tox/post.yaml b/playbooks/tox/post.yaml index 282fbe05e..e9eeeca48 100644 --- a/playbooks/tox/post.yaml +++ b/playbooks/tox/post.yaml @@ -1,34 +1,3 @@ - hosts: all - tasks: - - name: Find tox directories to synchrionize - find: - file_type: directory - paths: "src/{{ zuul.project.canonical_name }}/.tox" - # NOTE(pabelanger): The .tox/log folder is empty, ignore it. - patterns: ^(?!log).*$ - use_regex: yes - register: result - - - name: Set tox log path for multiple nodes - set_fact: - log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/tox" - when: groups['all'] | length > 1 - - - name: Set tox log path for single node - set_fact: - log_path: "{{ zuul.executor.log_root }}/tox" - when: log_path is not defined - - - name: Ensure local tox dir - file: - path: "{{ log_path }}" - state: directory - delegate_to: localhost - - - name: Collect tox logs - synchronize: - dest: "{{ log_path }}" - mode: pull - src: "{{ item.path }}/log/" - verify_host: true - with_items: "{{ result.files }}" + roles: + - fetch-tox-output diff --git a/roles/fetch-tox-output/README.rst b/roles/fetch-tox-output/README.rst new file mode 100644 index 000000000..7e1934b53 --- /dev/null +++ b/roles/fetch-tox-output/README.rst @@ -0,0 +1 @@ +Collect output from a tox build diff --git a/roles/fetch-tox-output/defaults/main.yaml b/roles/fetch-tox-output/defaults/main.yaml new file mode 100644 index 000000000..a0afa22c5 --- /dev/null +++ b/roles/fetch-tox-output/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +zuul_work_dir: "src/{{ zuul.project.canonical_name }}" diff --git a/roles/fetch-tox-output/tasks/main.yaml b/roles/fetch-tox-output/tasks/main.yaml new file mode 100644 index 000000000..31a6d0b5a --- /dev/null +++ b/roles/fetch-tox-output/tasks/main.yaml @@ -0,0 +1,32 @@ +- name: Find tox directories to synchrionize + find: + file_type: directory + paths: "{{ zuul_work_dir }}/.tox" + # NOTE(pabelanger): The .tox/log folder is empty, ignore it. + patterns: ^(?!log).*$ + use_regex: yes + register: result + +- name: Set tox log path for multiple nodes + set_fact: + log_path: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}/tox" + when: groups['all'] | length > 1 + +- name: Set tox log path for single node + set_fact: + log_path: "{{ zuul.executor.log_root }}/tox" + when: log_path is not defined + +- name: Ensure local tox dir + file: + path: "{{ log_path }}" + state: directory + delegate_to: localhost + +- name: Collect tox logs + synchronize: + dest: "{{ log_path }}" + mode: pull + src: "{{ item.path }}/log/" + verify_host: true + with_items: "{{ result.files }}"