diff --git a/playbooks/tripleo-buildcontainers/run.yaml b/playbooks/tripleo-buildcontainers/run.yaml index 98ae77c49..71e1d0454 100644 --- a/playbooks/tripleo-buildcontainers/run.yaml +++ b/playbooks/tripleo-buildcontainers/run.yaml @@ -12,6 +12,16 @@ push_tag: "{{ push_tag | default('latest') }}" push_containers: "{{ push_containers | default(false) | bool }}" + - name: Get contents of delorean repo baseurl for the version hash + become: true + shell: > + cat /etc/yum.repos.d/delorean.repo |awk -F= '/baseurl/ {print $2}' + register: baseurl + + - name: Set version_hash fact + set_fact: + version_hash: "{{ baseurl.stdout.split('/')[-1] }}" + - name: grab kolla patch if needed when: ansible_pkg_mgr == "dnf" shell: | @@ -72,3 +82,22 @@ > {{ workspace }}/build.log 2> {{ workspace }}/build-err.log RESULT=$? exit $RESULT + + - name: Retrieve the images by version_hash and retag with tripleo-ci-testing if periodic + when: + - zuul is defined + - "'periodic' in zuul.pipeline" + block: + - name: Retrieve list of built images + shell: > + docker images --format "{{ '{{' }}.Repository{{ '}}' }}" \ + --filter "reference=*:{{ version_hash }}" + register: built_images + + - name: Tag images + vars: + image: "{{ item }}" + include: tag.yml + static: no + with_items: "{{ built_images.stdout_lines }}" + diff --git a/playbooks/tripleo-buildcontainers/tag.yaml b/playbooks/tripleo-buildcontainers/tag.yaml new file mode 100644 index 000000000..2b339f8ff --- /dev/null +++ b/playbooks/tripleo-buildcontainers/tag.yaml @@ -0,0 +1,11 @@ +--- +- block: + # Tag and push in the same task for the sake of doing less tasks + - name: "Tag image: {{ image }}" + command: > + {{ cmd }} + with_items: + - "docker tag {{ image }}:{{ version_hash }} {{ image }}:{{ push_tag }}" + - "docker push {{ image }}:{{ push_tag }}" + loop_control: + loop_var: "cmd" diff --git a/playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j2 b/playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j2 index 38968afa9..1b77056b4 100644 --- a/playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j2 +++ b/playbooks/tripleo-buildcontainers/templates/kolla-build.conf.j2 @@ -2,7 +2,7 @@ base={{ ansible_distribution|lower }} type=binary registry={{ push_registry }} -tag={{ push_tag }} +tag={{ version_hash }} template_override={{ openstack_git_root }}/tripleo-common/container-images/tripleo_kolla_template_overrides.j2 # we use the repos off the main host as they will already have the correct mirror info in them rpm_setup_config=http://172.17.0.1/delorean.repo,http://172.17.0.1/delorean-{{ ci_branch }}-testing.repo