
We only need to alias registries on the build nodes when running docker. We cannot alias them in /etc/hosts in roles that are expected to run on localhost beacuse /etc/hosts is bindmounted read only on localhost. This assumes that skopeo handles ipv6 properly (which has not been tested). If skopeo does not handle ipv6 properly then we'll need additional fixing. Change-Id: I40e5b1bac5aeaf2d42aa05a72b9ced72b7d222c0
33 lines
1.4 KiB
YAML
33 lines
1.4 KiB
YAML
# 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 }}
|
|
loop: "{{ image.tags | default(['latest']) }}"
|
|
loop_control:
|
|
loop_var: image_tag
|
|
- name: Push tag to buildset registry
|
|
command: >-
|
|
docker push {{ buildset_registry_alias }}:{{ buildset_registry.port }}/{{ image.repository }}:{{ image_tag }}
|
|
loop: "{{ image.tags | default(['latest']) }}"
|
|
loop_control:
|
|
loop_var: image_tag
|