manila-image-elements/roles/build-mie-images/tasks/main.yml
Goutham Pacha Ravi a833b762d7 Modify job to build images
We currently only build the generic driver
image with the job "manila-image-elements-buildimage-generic".
Since we'd like to use a cephfs based client image,
we can reuse the job to produce two images instead
of one. The new job "manila-image-elements-buildimages"
produces two images: "manila-service-image-cephfs-{tag}.qcow2"
and "manila-service-image-{tag}.qcow2"; where the
tag corresponds to the version of this project.

The job also creates a soft link of the tagged images
with a "-master" suffix instead of the tag - this
is useful for CI jobs that don't need to worry
about changing/using the latest tag.

Change-Id: I60c6b38b5d5de7649c0d760519a79288fafca1e3
Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
2020-05-21 15:44:12 -07:00

54 lines
1.6 KiB
YAML

---
- name: build the requested images
command: bash -xe tools/gate/build-images {{ item }}
args:
chdir: "{{ zuul.project.src_dir }}"
with_items: "{{ images_to_build }}"
- name: create images directory
file:
path: "{{ zuul.project.src_dir }}/images"
state: directory
mode: 0755
- name: collect git tag
command: git describe --tags
args:
chdir: "{{ zuul.project.src_dir }}"
register: tagoutput
- name: show directory contents after the build
command: ls -lrt
args:
chdir: "{{ zuul.project.src_dir }}"
- name: get the source directory
command: pwd
args:
chdir: '{{ zuul.project.src_dir }}'
register: src_dir
- name: grab all images built
find:
paths: "{{ src_dir.stdout }}"
patterns: '*.qcow2'
file_type: file
register: images_built
- name: hard link images into the images directory using the git tag
file:
src: "{{ item.path }}"
dest: "{{ src_dir.stdout }}/images/{{ item.path | basename | splitext | first }}-{{ tagoutput.stdout }}.qcow2"
state: hard
with_items: "{{ images_built.files }}"
- name: grab the tagged images
find:
paths: "{{ src_dir.stdout }}/images"
patterns: "*.qcow2"
file_type: file
register: images_tagged
- name: create "master" symlinks for these images
file:
src: "{{ item.path }}"
dest: "{{ src_dir.stdout }}/images/{{ item.path | basename | regex_replace('\\d+.*qcow2', 'master.qcow2') }}"
state: link
with_items: "{{ images_tagged.files }}"
- name: get contents of the images directory
command: ls -lrt
args:
chdir: "{{ zuul.project.src_dir }}/images/"