29 lines
824 B
YAML
29 lines
824 B
YAML
---
|
|
-
|
|
name: Add registry mirror host entries
|
|
lineinfile:
|
|
path: /etc/hosts
|
|
regexp: "{{ item.mirror | urlsplit('hostname') | regex_escape }}"
|
|
line: "{{ registry_mirror_ip }} {{ item.mirror | urlsplit('hostname') }}"
|
|
loop: "{{ registry_mirrors }}"
|
|
when: registry_mirror_ip is defined
|
|
|
|
-
|
|
name: Configure Docker Hub registry mirror
|
|
copy:
|
|
dest: /etc/docker/daemon.json
|
|
content: |
|
|
{
|
|
"registry-mirrors": [
|
|
{% for item in registry_mirrors if item.upstream == 'docker.io' %}
|
|
"{{ item.mirror }}"{% if not loop.last %},{% endif %}
|
|
|
|
{% endfor %}
|
|
]
|
|
}
|
|
mode: "0644"
|
|
notify: restart docker
|
|
|
|
-
|
|
name: Ensure Docker is restarted if mirror changed
|
|
meta: flush_handlers
|