[stable/zed] Refactor image tags to be dynamic (#1122)

In order to simplify backporting and branching of new releases,
this patch relies on the Zuul branch when building images so
that we can easily branch out a new release and it will
automatically pick up the images.
Closes: #1121
diff --git a/zuul.d/container-images/barbican.yaml b/zuul.d/container-images/barbican.yaml
index 6e38ff6..73d178e 100644
--- a/zuul.d/container-images/barbican.yaml
+++ b/zuul.d/container-images/barbican.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=barbican
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/cinder.yaml b/zuul.d/container-images/cinder.yaml
index 66e83a6..fa7a675 100644
--- a/zuul.d/container-images/cinder.yaml
+++ b/zuul.d/container-images/cinder.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=cinder
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/cluster-api-provider-openstack.yaml b/zuul.d/container-images/cluster-api-provider-openstack.yaml
index 25a858b..53394e4 100644
--- a/zuul.d/container-images/cluster-api-provider-openstack.yaml
+++ b/zuul.d/container-images/cluster-api-provider-openstack.yaml
@@ -35,7 +35,7 @@
           arch:
             - linux/amd64
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/cluster-api-provider-openstack/.*
 
diff --git a/zuul.d/container-images/designate.yaml b/zuul.d/container-images/designate.yaml
index ed9719a..9ff13fd 100644
--- a/zuul.d/container-images/designate.yaml
+++ b/zuul.d/container-images/designate.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=designate
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/glance.yaml b/zuul.d/container-images/glance.yaml
index a9aa580..69b5433 100644
--- a/zuul.d/container-images/glance.yaml
+++ b/zuul.d/container-images/glance.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=glance
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/heat.yaml b/zuul.d/container-images/heat.yaml
index 2492adc..52403ef 100644
--- a/zuul.d/container-images/heat.yaml
+++ b/zuul.d/container-images/heat.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=heat
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/horizon.yaml b/zuul.d/container-images/horizon.yaml
index 389e828..914053d 100644
--- a/zuul.d/container-images/horizon.yaml
+++ b/zuul.d/container-images/horizon.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=horizon
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/ironic.yaml b/zuul.d/container-images/ironic.yaml
index 462d12d..3e16dd1 100644
--- a/zuul.d/container-images/ironic.yaml
+++ b/zuul.d/container-images/ironic.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=ironic
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/keepalived.yaml b/zuul.d/container-images/keepalived.yaml
index 11d66cf..68f462a 100644
--- a/zuul.d/container-images/keepalived.yaml
+++ b/zuul.d/container-images/keepalived.yaml
@@ -37,8 +37,10 @@
           repository: registry.atmosphere.dev/library/keepalived
           arch:
             - linux/amd64
+          build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/keepalived/.*
diff --git a/zuul.d/container-images/keystone.yaml b/zuul.d/container-images/keystone.yaml
index 84d58a5..791f3ce 100644
--- a/zuul.d/container-images/keystone.yaml
+++ b/zuul.d/container-images/keystone.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=keystone
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/kubernetes-entrypoint.yaml b/zuul.d/container-images/kubernetes-entrypoint.yaml
index 3c6a60b..ea04bde 100644
--- a/zuul.d/container-images/kubernetes-entrypoint.yaml
+++ b/zuul.d/container-images/kubernetes-entrypoint.yaml
@@ -35,7 +35,7 @@
           arch:
             - linux/amd64
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/kubernetes-entrypoint/.*
 
diff --git a/zuul.d/container-images/libvirt-tls-sidecar.yaml b/zuul.d/container-images/libvirt-tls-sidecar.yaml
index 734bc5b..76dfd48 100644
--- a/zuul.d/container-images/libvirt-tls-sidecar.yaml
+++ b/zuul.d/container-images/libvirt-tls-sidecar.yaml
@@ -38,8 +38,10 @@
           repository: registry.atmosphere.dev/library/libvirt-tls-sidecar
           arch:
             - linux/amd64
+          build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - cmd/.*
diff --git a/zuul.d/container-images/libvirtd.yaml b/zuul.d/container-images/libvirtd.yaml
index 77b6ecc..dc2d6d2 100644
--- a/zuul.d/container-images/libvirtd.yaml
+++ b/zuul.d/container-images/libvirtd.yaml
@@ -42,9 +42,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=nova
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/magnum.yaml b/zuul.d/container-images/magnum.yaml
index 55e009d..234e591 100644
--- a/zuul.d/container-images/magnum.yaml
+++ b/zuul.d/container-images/magnum.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=magnum
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/manila.yaml b/zuul.d/container-images/manila.yaml
index 7655da2..2d71690 100644
--- a/zuul.d/container-images/manila.yaml
+++ b/zuul.d/container-images/manila.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=manila
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/netoffload.yaml b/zuul.d/container-images/netoffload.yaml
index 58cba39..2ca86b4 100644
--- a/zuul.d/container-images/netoffload.yaml
+++ b/zuul.d/container-images/netoffload.yaml
@@ -37,8 +37,10 @@
           repository: registry.atmosphere.dev/library/netoffload
           arch:
             - linux/amd64
+          build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/netoffload/.*
diff --git a/zuul.d/container-images/neutron.yaml b/zuul.d/container-images/neutron.yaml
index 4758952..5612ff8 100644
--- a/zuul.d/container-images/neutron.yaml
+++ b/zuul.d/container-images/neutron.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=neutron
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/nova-ssh.yaml b/zuul.d/container-images/nova-ssh.yaml
index 8c60c07..d7801c1 100644
--- a/zuul.d/container-images/nova-ssh.yaml
+++ b/zuul.d/container-images/nova-ssh.yaml
@@ -42,9 +42,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=nova
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/nova.yaml b/zuul.d/container-images/nova.yaml
index d16d032..5b415c3 100644
--- a/zuul.d/container-images/nova.yaml
+++ b/zuul.d/container-images/nova.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=nova
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/octavia.yaml b/zuul.d/container-images/octavia.yaml
index 0b79b4f..e8555a3 100644
--- a/zuul.d/container-images/octavia.yaml
+++ b/zuul.d/container-images/octavia.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=octavia
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/openstack-python-runtime.yaml b/zuul.d/container-images/openstack-python-runtime.yaml
index 3ef1110..5a7ce33 100644
--- a/zuul.d/container-images/openstack-python-runtime.yaml
+++ b/zuul.d/container-images/openstack-python-runtime.yaml
@@ -42,9 +42,10 @@
           arch:
             - linux/amd64
           build_args:
-            - FROM=registry.atmosphere.dev/library/python-base:zed
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
+            - "FROM=registry.atmosphere.dev/library/python-base:{{ zuul.branch | replace('stable/', '') }}"
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/openstack-runtime.yaml b/zuul.d/container-images/openstack-runtime.yaml
index 039c880..cde0737 100644
--- a/zuul.d/container-images/openstack-runtime.yaml
+++ b/zuul.d/container-images/openstack-runtime.yaml
@@ -39,8 +39,10 @@
           repository: registry.atmosphere.dev/library/openstack-runtime
           arch:
             - linux/amd64
+          build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/openstack-venv-builder.yaml b/zuul.d/container-images/openstack-venv-builder.yaml
index 73767b5..a50ee93 100644
--- a/zuul.d/container-images/openstack-venv-builder.yaml
+++ b/zuul.d/container-images/openstack-venv-builder.yaml
@@ -41,8 +41,10 @@
           repository: registry.atmosphere.dev/library/openstack-venv-builder
           arch:
             - linux/amd64
+          build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/openvswitch.yaml b/zuul.d/container-images/openvswitch.yaml
index 542616b..67a55c6 100644
--- a/zuul.d/container-images/openvswitch.yaml
+++ b/zuul.d/container-images/openvswitch.yaml
@@ -35,7 +35,7 @@
           arch:
             - linux/amd64
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/openvswitch/.*
 
diff --git a/zuul.d/container-images/ovn.yaml b/zuul.d/container-images/ovn.yaml
index 66242ad..5a3e180 100644
--- a/zuul.d/container-images/ovn.yaml
+++ b/zuul.d/container-images/ovn.yaml
@@ -38,18 +38,20 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - OVN_COMPONENT=central
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
         - context: images/ovn
           registry: registry.atmosphere.dev
           repository: registry.atmosphere.dev/library/ovn-host
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - OVN_COMPONENT=host
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/openvswitch/.*
       - images/ovn/.*
diff --git a/zuul.d/container-images/placement.yaml b/zuul.d/container-images/placement.yaml
index 765e950..d020a79 100644
--- a/zuul.d/container-images/placement.yaml
+++ b/zuul.d/container-images/placement.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=placement
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/python-base.yaml b/zuul.d/container-images/python-base.yaml
index e88a9c6..3e63e8c 100644
--- a/zuul.d/container-images/python-base.yaml
+++ b/zuul.d/container-images/python-base.yaml
@@ -39,8 +39,10 @@
           repository: registry.atmosphere.dev/library/python-base
           arch:
             - linux/amd64
+          build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/senlin.yaml b/zuul.d/container-images/senlin.yaml
index cb3592e..fc12aa0 100644
--- a/zuul.d/container-images/senlin.yaml
+++ b/zuul.d/container-images/senlin.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=senlin
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/staffeln.yaml b/zuul.d/container-images/staffeln.yaml
index e765381..db01912 100644
--- a/zuul.d/container-images/staffeln.yaml
+++ b/zuul.d/container-images/staffeln.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=staffeln
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/tempest.yaml b/zuul.d/container-images/tempest.yaml
index 8d321a5..1d81749 100644
--- a/zuul.d/container-images/tempest.yaml
+++ b/zuul.d/container-images/tempest.yaml
@@ -46,9 +46,10 @@
           arch:
             - linux/amd64
           build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
             - PROJECT=tempest
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/ubuntu-cloud-archive.yaml b/zuul.d/container-images/ubuntu-cloud-archive.yaml
index a643e3a..d2d23ba 100644
--- a/zuul.d/container-images/ubuntu-cloud-archive.yaml
+++ b/zuul.d/container-images/ubuntu-cloud-archive.yaml
@@ -37,8 +37,10 @@
           repository: registry.atmosphere.dev/library/ubuntu-cloud-archive
           arch:
             - linux/amd64
+          build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
       - images/ubuntu-cloud-archive/.*
diff --git a/zuul.d/container-images/ubuntu.yaml b/zuul.d/container-images/ubuntu.yaml
index 6fb76d3..5e39b95 100644
--- a/zuul.d/container-images/ubuntu.yaml
+++ b/zuul.d/container-images/ubuntu.yaml
@@ -34,8 +34,10 @@
           repository: registry.atmosphere.dev/library/ubuntu
           arch:
             - linux/amd64
+          build_args:
+            - "RELEASE={{ zuul.branch | replace('stable/', '') }}"
           tags:
-            - zed
+            - "{{ zuul.branch | replace('stable/', '') }}"
     files: &container_image_files
       - images/ubuntu/.*
 
diff --git a/zuul.d/playbooks/molecule/pre.yml b/zuul.d/playbooks/molecule/pre.yml
index a4bc692..9e10180 100644
--- a/zuul.d/playbooks/molecule/pre.yml
+++ b/zuul.d/playbooks/molecule/pre.yml
@@ -59,15 +59,14 @@
         - name: Replace the registry in image manifest
           ansible.builtin.replace:
             path: "{{ zuul.project.src_dir }}/roles/defaults/vars/main.yml"
-            regexp: "{{ repo }}:{{ tag }}"
-            replace: '{{ buildset_registry.host }}:{{ buildset_registry.port }}/{{ repo }}:{{ tag }}'
+            regexp: "{{ repo }}:"
+            replace: '{{ buildset_registry.host }}:{{ buildset_registry.port }}/{{ repo }}:'
           loop: "{{ zuul.artifacts | default([]) }}"
           loop_control:
             loop_var: zj_zuul_artifact
           when: "'metadata' in zj_zuul_artifact and zj_zuul_artifact.metadata.type | default('') == 'container_image'"
           vars:
             repo: "{{ zj_zuul_artifact.metadata.repository }}"
-            tag: "{{ zj_zuul_artifact.metadata.tag }}"
 
     # TODO(mnaser): Drop this when we move to PBR
     - name: Add current folder to Git's safe directories