summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@redhat.com>2019-01-31 10:48:58 -0800
committerJames E. Blair <jeblair@redhat.com>2019-01-31 10:48:58 -0800
commit98628f718aa984a7b6b58711f34d8ea0b982d88f (patch)
tree679977d07f151f788c33168cf2e02fb0085d4fb4
parent2abb8a130212bdf0fc7bb453f586d069cba2aa6f (diff)
stage-output: Add the ability to add .txt extensions to files
So that this can more easily work with files like '/var/log/syslog', make it so that if the user specifies "logs_txt" then the file gets a .txt extension before being placed in the logs directory. The existing extensions_to_txt variable doesn't work for this because it requires an existing extension. Change-Id: I34fea0c44030c04a5540d6b62976557143289196
Notes
Notes (review): Code-Review+2: Andreas Jaeger <jaegerandi@gmail.com> Code-Review+2: Monty Taylor <mordred@inaugust.com> Workflow+1: Monty Taylor <mordred@inaugust.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Sat, 02 Feb 2019 07:18:51 +0000 Reviewed-on: https://review.openstack.org/634293 Project: openstack-infra/zuul-jobs Branch: refs/heads/master
-rw-r--r--roles/stage-output/README.rst10
-rw-r--r--roles/stage-output/tasks/main.yaml7
2 files changed, 14 insertions, 3 deletions
diff --git a/roles/stage-output/README.rst b/roles/stage-output/README.rst
index 9da1b4d..df74640 100644
--- a/roles/stage-output/README.rst
+++ b/roles/stage-output/README.rst
@@ -23,6 +23,16 @@ intended to be used before output fetching in a base job's post-playbook.
23 null overrides the will of a parent job to copy something instructing 23 null overrides the will of a parent job to copy something instructing
24 not to copy. 24 not to copy.
25 25
26 If the type is suffixed with ``_txt``, then the item will have
27 ``.txt`` appended to its name. For example::
28
29 .. code-block:: yaml
30
31 zuul_copy_output:
32 /var/log/syslog: logs_txt
33
34 Will copy ``/var/log/syslog`` to ``logs/syslog.txt``.
35
26.. zuul:rolevar:: stage_dir 36.. zuul:rolevar:: stage_dir
27 :default: {{ ansible_user_dir }} 37 :default: {{ ansible_user_dir }}
28 38
diff --git a/roles/stage-output/tasks/main.yaml b/roles/stage-output/tasks/main.yaml
index bee689b..5d88907 100644
--- a/roles/stage-output/tasks/main.yaml
+++ b/roles/stage-output/tasks/main.yaml
@@ -27,12 +27,13 @@
27# NOTE(andreaf) Files or folders that start with a '.' are renamed to starting 27# NOTE(andreaf) Files or folders that start with a '.' are renamed to starting
28# with an '_' else they would not be visible in the logs folder once uploaded. 28# with an '_' else they would not be visible in the logs folder once uploaded.
29# Extension changes are handled later via find as we want to rename files 29# Extension changes are handled later via find as we want to rename files
30# included of folders specified in `zuul_copy_output`. 30# included of folders specified in `zuul_copy_output` (except for logs_txt,
31# which is handled here).
31- name: Set source and destination for files and folders 32- name: Set source and destination for files and folders
32 set_fact: 33 set_fact:
33 source: "{{ item.stat.path }}" 34 source: "{{ item.stat.path }}"
34 dest: "{{ item.item.value }}/{{ item.stat.path|basename|regex_replace('^(\\..*)$', '_\\1') }}" 35 dest: "{{ item.item.value.split('_')[0] }}/{{ item.stat.path|basename|regex_replace('^(\\..*)$', '_\\1') }}{% if item.item.value.endswith('_txt') %}.txt{% endif %}"
35 type: "{{ item.item.value }}" 36 type: "{{ item.item.value.split('_')[0] }}"
36 with_items: "{{ sources.results }}" 37 with_items: "{{ sources.results }}"
37 when: 38 when:
38 - item.stat.exists 39 - item.stat.exists