magnum/playbooks/container-builder.yaml
Bharat Kunwar ff57593984 [hca] Only build/push stable images if unpublished
At present, the only mechanism we have for publishing a stable heat
container agent image through manual tagging. This PS aims to automate
this through the CI by only building them if they have not already been
published. This should allow us to keep better track of which commit was
used to build a given heat container agent image.

Story: 2007264
Task: 40045

Change-Id: Ifb80575c18a34584afddc8b83084702713a802b7
2021-03-03 12:21:18 +00:00

69 lines
2.7 KiB
YAML

- hosts: all
tasks:
- include_vars: container-builder-vars.yaml
# NOTE: By default, stable images are not built if they already exist.
# Assigning dev=true property for heat container agent images means that a new
# image is re-built and pushed under the same tag every time.
- name: "Build heat-container-agent images"
block:
- name: "Check if {{ magnum_repository }}/heat-container-agent:{{ item.tag }} exists"
docker_image:
name: "{{ magnum_repository }}/heat-container-agent"
tag: "{{ item.tag }}"
pull: yes
register: docker_output
when: not (item.dev | default(false) | bool)
ignore_errors: true
with_items: "{{ heat_container_agent_images }}"
- name: "Build {{ magnum_repository }}/heat-container-agent:{{ item.item.tag }} image"
docker_image:
path: "{{ magnum_src_dir }}/dockerfiles/heat-container-agent"
name: "{{ magnum_repository }}/heat-container-agent"
tag: "{{ item.item.tag }}"
push: no
source: build
with_items: "{{ docker_output.results }}"
when: (item is failed) or (item.item.dev | default(false) | bool)
retries: 10
- name: "Build kubernetes images"
block:
- name: "Build {{ magnum_repository }}/{{ item[1].name }}:{{ item[0].version }} image"
docker_image:
path: "{{ magnum_src_dir }}/dockerfiles/{{ item[1].name }}"
name: "{{ magnum_repository }}/{{ item[1].name }}"
tag: "{{ item[0].version }}"
buildargs:
KUBE_VERSION: "{{ item[0].version }}"
push: no
with_nested:
- "{{ kubernetes_versions }}"
- "{{ kubernetes_images }}"
retries: 10
- name: "Build helm-client image"
block:
- docker_image:
path: "{{ magnum_src_dir }}/dockerfiles/helm-client"
name: "{{ magnum_repository }}/helm-client"
tag: "{{ item.version }}"
buildargs:
HELM_VERSION: "{{ item.version }}"
push: no
with_items: "{{ helm_versions }}"
retries: 10
- name: "Build cluster-autoscaler image"
block:
- name: "Build {{ magnum_repository }}/cluster-autoscaler:v{{ item.version }}"
docker_image:
path: "{{ magnum_src_dir }}/dockerfiles/cluster-autoscaler"
name: "{{ magnum_repository }}/cluster-autoscaler"
tag: "v{{ item.version }}"
buildargs:
AUTOSCALER_VERSION: "cluster-autoscaler-{{ item.version }}"
push: no
with_items: "{{ cluster_autoscaler_versions }}"
retries: 10