Browse Source

Split docker mirror config into its own role

So that the docker mirror configuration can be used without the
install-docker role (e.g., if another process is used to install
docker on a target host), split the part of the role which
configures mirrors into its own role and include it in the
install-docker role.

Change-Id: I7cd7f61e2d1281cd2949c1f69a081c7217d0d328
changes/95/638195/8
James E. Blair 3 months ago
parent
commit
90fc18f621

+ 2
- 10
roles/install-docker/tasks/main.yaml View File

@@ -1,14 +1,6 @@
1
-- name: Set mirror_fqdn fact
2
-  when:
3
-    - mirror_fqdn is not defined
4
-    - zuul_site_mirror_fqdn is defined
5
-  set_fact:
6
-    mirror_fqdn: "{{ zuul_site_mirror_fqdn }}"
7
-
8 1
 - name: Set up docker mirrors
9
-  include: mirror.yaml
10
-  when: mirror_fqdn is defined
11
-  static: no
2
+  include_role:
3
+    name: use-docker-mirror
12 4
 
13 5
 - name: Install docker-ce from upstream
14 6
   include: upstream.yaml

+ 20
- 0
roles/use-docker-mirror/README.rst View File

@@ -0,0 +1,20 @@
1
+Configure docker to use mirrors if available.
2
+
3
+**Role Variables**
4
+
5
+.. zuul:rolevar:: mirror_fqdn
6
+   :default: {{ zuul_site_mirror_fqdn }}
7
+
8
+   The base host for mirror servers.
9
+
10
+.. zuul:rolevar:: docker_mirror
11
+
12
+   URL to override the generated docker hub mirror url based on
13
+   :zuul:rolevar:`install-docker.mirror_fqdn`.
14
+
15
+.. zuul:rolevar:: docker_insecure_registries
16
+   :default: undefined
17
+
18
+   Declare this with a list of insecure registries to define the
19
+   registries which are allowed to communicate with HTTP only or
20
+   HTTPS with no valid certificate.

+ 11
- 0
roles/use-docker-mirror/tasks/main.yaml View File

@@ -0,0 +1,11 @@
1
+- name: Set mirror_fqdn fact
2
+  when:
3
+    - mirror_fqdn is not defined
4
+    - zuul_site_mirror_fqdn is defined
5
+  set_fact:
6
+    mirror_fqdn: "{{ zuul_site_mirror_fqdn }}"
7
+
8
+- name: Set up docker mirrors
9
+  include: mirror.yaml
10
+  when: mirror_fqdn is defined
11
+  static: no

roles/install-docker/tasks/mirror.yaml → roles/use-docker-mirror/tasks/mirror.yaml View File


+ 4
- 0
roles/use-docker-mirror/templates/daemon.json.j2 View File

@@ -0,0 +1,4 @@
1
+{
2
+  {% if docker_insecure_registries is defined -%}"insecure-registries": {{ docker_insecure_registries | to_json }},{% endif %}
3
+  "registry-mirrors": ["{{ docker_mirror }}"]
4
+}

Loading…
Cancel
Save