diff --git a/roles/install-docker/tasks/main.yaml b/roles/install-docker/tasks/main.yaml index d0da85bac..45b9684d7 100644 --- a/roles/install-docker/tasks/main.yaml +++ b/roles/install-docker/tasks/main.yaml @@ -1,14 +1,6 @@ -- name: Set mirror_fqdn fact - when: - - mirror_fqdn is not defined - - zuul_site_mirror_fqdn is defined - set_fact: - mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" - - name: Set up docker mirrors - include: mirror.yaml - when: mirror_fqdn is defined - static: no + include_role: + name: use-docker-mirror - name: Install docker-ce from upstream include: upstream.yaml diff --git a/roles/use-docker-mirror/README.rst b/roles/use-docker-mirror/README.rst new file mode 100644 index 000000000..aedcb4946 --- /dev/null +++ b/roles/use-docker-mirror/README.rst @@ -0,0 +1,20 @@ +Configure docker to use mirrors if available. + +**Role Variables** + +.. zuul:rolevar:: mirror_fqdn + :default: {{ zuul_site_mirror_fqdn }} + + The base host for mirror servers. + +.. zuul:rolevar:: docker_mirror + + URL to override the generated docker hub mirror url based on + :zuul:rolevar:`install-docker.mirror_fqdn`. + +.. zuul:rolevar:: docker_insecure_registries + :default: undefined + + Declare this with a list of insecure registries to define the + registries which are allowed to communicate with HTTP only or + HTTPS with no valid certificate. diff --git a/roles/use-docker-mirror/tasks/main.yaml b/roles/use-docker-mirror/tasks/main.yaml new file mode 100644 index 000000000..dd65f951e --- /dev/null +++ b/roles/use-docker-mirror/tasks/main.yaml @@ -0,0 +1,11 @@ +- name: Set mirror_fqdn fact + when: + - mirror_fqdn is not defined + - zuul_site_mirror_fqdn is defined + set_fact: + mirror_fqdn: "{{ zuul_site_mirror_fqdn }}" + +- name: Set up docker mirrors + include: mirror.yaml + when: mirror_fqdn is defined + static: no diff --git a/roles/install-docker/tasks/mirror.yaml b/roles/use-docker-mirror/tasks/mirror.yaml similarity index 100% rename from roles/install-docker/tasks/mirror.yaml rename to roles/use-docker-mirror/tasks/mirror.yaml diff --git a/roles/use-docker-mirror/templates/daemon.json.j2 b/roles/use-docker-mirror/templates/daemon.json.j2 new file mode 100644 index 000000000..252081880 --- /dev/null +++ b/roles/use-docker-mirror/templates/daemon.json.j2 @@ -0,0 +1,4 @@ +{ + {% if docker_insecure_registries is defined -%}"insecure-registries": {{ docker_insecure_registries | to_json }},{% endif %} + "registry-mirrors": ["{{ docker_mirror }}"] +}