Clark Boylan 589cccb055 Fix dockerhub check in use-docker-mirror role
We were checking if dockerhub is a valid key in the
zuul_site_mirror_info/mirror_info dictionaries but did so without
quoting dockerhub as a string. This meant ansible tried to look up
dockerhub as a variable producing this error:

  The conditional check 'dockerhub is in zuul_site_mirror_info' failed.
  The error was: error while evaluating conditional (dockerhub is in
  zuul_site_mirror_info): 'dockerhub' is undefined. 'dockerhub' is undefined

Fix this by quoting dockerhub so that we lookup the string as a key
instead of a variable.

Change-Id: Ie869b9b52fd0a5b70fc07548ce449937ed2c9589
2024-11-20 23:06:10 +00:00

33 lines
1.1 KiB
YAML

- name: Set docker_mirror fact from mirror_info
when:
- docker_mirror is not defined
- mirror_info is defined
- "'dockerhub' is in mirror_info"
set_fact:
docker_mirror: mirror_info.dockerhub.url
- name: Set docker_mirror fact from zuul_site_mirror_info
when:
- docker_mirror is not defined
- zuul_site_mirror_info is defined
- "'dockerhub' is in zuul_site_mirror_info"
set_fact:
docker_mirror: zuul_site_mirror_info.dockerhub.url
# Backward compat fallback to old style mirror_fqdn based url derivation.
- name: Set docker_mirror fact
when:
- docker_mirror is not defined
- mirror_info is not defined
- zuul_site_mirror_info is not defined
- mirror_fqdn is defined or zuul_site_mirror_fqdn is defined
set_fact:
docker_mirror: "http://{{ mirror_fqdn | default(zuul_site_mirror_fqdn) }}:8082"
# Only run when new style mirror_info is defined or old style mirror
# info is defined and not new style. This forces people using new
# style to configure dockerhub mirroring there.
- name: Set up docker mirrors
include_tasks: mirror.yaml
when: docker_mirror is defined