diff --git a/roles/build-docker-image/tasks/main.yaml b/roles/build-docker-image/tasks/main.yaml index 4a09643f0..58796ab2f 100644 --- a/roles/build-docker-image/tasks/main.yaml +++ b/roles/build-docker-image/tasks/main.yaml @@ -20,6 +20,26 @@ args: chdir: "{{ zuul_work_dir }}/{{ item.context }}" loop: "{{ docker_images }}" +# Docker doesn't understand docker push [1234:5678::]:5000/image/path:tag +# so we set up /etc/hosts with a registry alias name to support ipv6 and 4. +- name: Configure /etc/hosts for buildset_registry to workaround docker not understanding ipv6 addresses + become: yes + lineinfile: + path: /etc/hosts + state: present + regex: "^{{ buildset_registry.host }}\tzuul-jobs.buildset-registry$" + line: "{{ buildset_registry.host }}\tzuul-jobs.buildset-registry" + insertafter: EOF + when: buildset_registry.host | ipaddr +- name: Set buildset_registry alias variable when using ip + set_fact: + buildset_registry_alias: zuul-jobs.buildset-registry + when: buildset_registry.host | ipaddr +- name: Set buildset_registry alias variable when using name + set_fact: + buildset_registry_alias: "{{ buildset_registry.host }}" + when: not ( buildset_registry.host | ipaddr ) +# Push each image. - name: Push image to buildset registry when: buildset_registry is defined include_tasks: push.yaml diff --git a/roles/build-docker-image/tasks/push.yaml b/roles/build-docker-image/tasks/push.yaml index 0b8191934..aba3b4e96 100644 --- a/roles/build-docker-image/tasks/push.yaml +++ b/roles/build-docker-image/tasks/push.yaml @@ -1,23 +1,3 @@ -# Docker doesn't understand docker push [1234:5678::]:5000/image/path:tag -# so we set up /etc/hosts with a registry alias name to support ipv6 and 4. -- name: Configure /etc/hosts for buildset_registry to workaround docker not understanding ipv6 addresses - become: yes - lineinfile: - path: /etc/hosts - state: present - regex: "^{{ buildset_registry.host }}\tzuul-jobs.buildset-registry$" - line: "{{ buildset_registry.host }}\tzuul-jobs.buildset-registry" - insertafter: EOF - when: buildset_registry.host | ipaddr -- name: Set buildset_registry alias variable when using ip - set_fact: - buildset_registry_alias: zuul-jobs.buildset-registry - when: buildset_registry.host | ipaddr -- name: Set buildset_registry alias variable when using name - set_fact: - buildset_registry_alias: "{{ buildset_registry.host }}" - when: not ( buildset_registry.host | ipaddr ) - - name: Tag image for buildset registry command: >- docker tag {{ image.repository }}:{{ image_tag }} {{ buildset_registry_alias }}:{{ buildset_registry.port }}/{{ image.repository }}:{{ image_tag }}