Files
James E. Blair b4ebca61cc Allow disabling compression of uploaded images
This may not be required for openstack, but let's maintain parity
between the swift and s3 upload roles.

Change-Id: I3740528d90b27ca36d742b6069014a395252a1f3
Co-Authored-By: Simon Westphahl <simon.westphahl@bmw.de>
2025-10-10 09:29:23 -07:00

86 lines
2.6 KiB
YAML

# Run the checksums in the background while we're working
- name: Get sha256 hash
stat:
path: '{{ upload_image_swift_filename }}'
checksum_algorithm: sha256
async: '{{ upload_image_swift_hash_timeout }}'
poll: 0
register: sha256_task
- name: Get md5 hash
stat:
path: '{{ upload_image_swift_filename }}'
checksum_algorithm: md5
async: '{{ upload_image_swift_hash_timeout }}'
poll: 0
register: md5_task
- name: Set extension
set_fact:
zj_upload_image_swift_extension: ''
- name: Compress image
when:
- "upload_image_swift_compress_image"
block:
- name: Check if zstd is installed
shell: "command -v zstd || exit 1"
register: zstd_installed
failed_when: false
- name: Compress image
when:
- "zstd_installed.rc == 0"
- "upload_image_swift_format in ['raw', 'vhd']"
command: zstd '{{ upload_image_swift_filename }}'
- name: Set extension
when:
- "zstd_installed.rc == 0"
- "upload_image_swift_format in ['raw', 'vhd']"
set_fact:
zj_upload_image_swift_extension: '.zst'
- name: Upload image to swift
upload_image_swift:
cloud: '{{ upload_image_swift_cloud_config }}'
container: '{{ upload_image_swift_container }}'
filename: '{{ upload_image_swift_filename }}{{ zj_upload_image_swift_extension }}'
name: '{{ upload_image_swift_name }}{{ zj_upload_image_swift_extension }}'
delete_after: '{{ upload_image_swift_delete_after }}'
register: upload_results
- name: Delete uncompressed image
when: "upload_image_swift_format in ['raw', 'vhd']"
command: rm '{{ upload_image_swift_filename }}'
- name: Wait for sha256
async_status:
jid: "{{ sha256_task.ansible_job_id }}"
register: sha256
until: sha256.finished
retries: "{{ (upload_image_swift_hash_timeout > 10) | ternary(upload_image_swift_hash_timeout // 10, 10) }}"
delay: 10
- name: Wait for md5
async_status:
jid: "{{ md5_task.ansible_job_id }}"
register: md5
until: md5.finished
retries: "{{ (upload_image_swift_hash_timeout > 10) | ternary(upload_image_swift_hash_timeout // 10, 10) }}"
delay: 10
- name: Return artifact to Zuul
zuul_return:
data:
zuul:
artifacts:
- name: '{{ upload_image_swift_format }} image'
url: '{{ upload_results.url }}'
metadata:
type: 'zuul_image'
image_name: '{{ upload_image_swift_image_name }}'
format: '{{ upload_image_swift_format }}'
sha256: '{{ sha256.stat.checksum }}'
md5sum: '{{ md5.stat.checksum }}'