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
This commit is contained in:
parent
2abb8a1302
commit
98628f718a
@ -23,6 +23,16 @@ intended to be used before output fetching in a base job's post-playbook.
|
|||||||
null overrides the will of a parent job to copy something instructing
|
null overrides the will of a parent job to copy something instructing
|
||||||
not to copy.
|
not to copy.
|
||||||
|
|
||||||
|
If the type is suffixed with ``_txt``, then the item will have
|
||||||
|
``.txt`` appended to its name. For example::
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
zuul_copy_output:
|
||||||
|
/var/log/syslog: logs_txt
|
||||||
|
|
||||||
|
Will copy ``/var/log/syslog`` to ``logs/syslog.txt``.
|
||||||
|
|
||||||
.. zuul:rolevar:: stage_dir
|
.. zuul:rolevar:: stage_dir
|
||||||
:default: {{ ansible_user_dir }}
|
:default: {{ ansible_user_dir }}
|
||||||
|
|
||||||
|
@ -27,12 +27,13 @@
|
|||||||
# NOTE(andreaf) Files or folders that start with a '.' are renamed to starting
|
# NOTE(andreaf) Files or folders that start with a '.' are renamed to starting
|
||||||
# with an '_' else they would not be visible in the logs folder once uploaded.
|
# with an '_' else they would not be visible in the logs folder once uploaded.
|
||||||
# Extension changes are handled later via find as we want to rename files
|
# Extension changes are handled later via find as we want to rename files
|
||||||
# included of folders specified in `zuul_copy_output`.
|
# included of folders specified in `zuul_copy_output` (except for logs_txt,
|
||||||
|
# which is handled here).
|
||||||
- name: Set source and destination for files and folders
|
- name: Set source and destination for files and folders
|
||||||
set_fact:
|
set_fact:
|
||||||
source: "{{ item.stat.path }}"
|
source: "{{ item.stat.path }}"
|
||||||
dest: "{{ item.item.value }}/{{ item.stat.path|basename|regex_replace('^(\\..*)$', '_\\1') }}"
|
dest: "{{ item.item.value.split('_')[0] }}/{{ item.stat.path|basename|regex_replace('^(\\..*)$', '_\\1') }}{% if item.item.value.endswith('_txt') %}.txt{% endif %}"
|
||||||
type: "{{ item.item.value }}"
|
type: "{{ item.item.value.split('_')[0] }}"
|
||||||
with_items: "{{ sources.results }}"
|
with_items: "{{ sources.results }}"
|
||||||
when:
|
when:
|
||||||
- item.stat.exists
|
- item.stat.exists
|
||||||
|
Loading…
Reference in New Issue
Block a user