Add compress capabilities to stage artifacts

Compress files and files in folders. Use gz by default.

Change-Id: I72796e64a65fe88d85168734ac881ee3ec2ce100
This commit is contained in:
Andrea Frittoli (andreaf) 2017-10-03 17:24:32 +01:00 committed by Andrea Frittoli
parent d0851b0b4a
commit 2ea8661801
3 changed files with 21 additions and 0 deletions

View File

@ -47,3 +47,8 @@ intended to be used before output fetching in a base job's post-playbook.
- log
zuul.conf --(staged as)--> zuul_conf.txt
.. zuul:rolevar:: stage_compress_logs
:default: True
When True, files staged as logs will be compressed individually.

View File

@ -1,2 +1,3 @@
stage_dir: "{{ ansible_user_dir }}"
extensions_to_txt:
stage_compress_logs: true

View File

@ -19,6 +19,7 @@
set_fact:
source: "{{ item.stat.path }}"
dest: "{{ item.item.value }}/{{ item.stat.path|basename|regex_replace('\\.(' + extensions_regex + ')$', '_\\1.txt') }}"
type: "{{ item.item.value }}"
with_items: "{{ sources.results }}"
when:
- item.stat.exists
@ -45,3 +46,17 @@
# zuul, using command
command: cp -pR {{ item.source}} {{ stage_dir }}/{{ item.dest }}
with_items: "{{ all_sources }}"
# NOTE(andreaf) The ansible module does not support recursive archive, so
# using gzip is the only option here. The good bit is that gzip itself is
# almost idempotent, as it will not compress again files with .gz extension.
# gzip will however return 1 if any compressed file is encountered, so we
# must ignore that (there's no specific error code).
- name: Archive everything from docs sources
shell: gzip --recursive --best {{ item.dest }} || true
args:
chdir: "{{ stage_dir }}"
with_items: "{{ all_sources }}"
when:
- stage_compress_logs
- item.type == 'logs'