
To accomodate running in a production-simulation environment, make it safe to run this role on a host before docker is installed. This also adds support for the new dual-registry configuration that run-buildset-registry uses. This removes the region-local proxy from the registry-mirrors configuration. Because the buildset registry acts as a pull-through proxy, the region-local proxy won't be used even if we did include it. Instead, we should update the run-buildset-registry role to proxy to the region-local proxy if present. Change-Id: I21011a3708f17ee61afd0034d90d75e8dc885575
44 lines
1.5 KiB
YAML
44 lines
1.5 KiB
YAML
# Update user config
|
|
- name: Ensure docker user directory exists
|
|
file:
|
|
state: directory
|
|
path: "~/.docker"
|
|
mode: 0700
|
|
- name: Check if docker user configuration exists
|
|
stat:
|
|
path: "~/.docker/config.json"
|
|
register: docker_config_stat
|
|
- name: Load docker user configuration
|
|
when: docker_config_stat.stat.exists
|
|
slurp:
|
|
path: "~/.docker/config.json"
|
|
register: docker_config
|
|
- name: Parse docker user configuration
|
|
when: docker_config_stat.stat.exists
|
|
set_fact:
|
|
docker_config: "{{ docker_config.content | b64decode | from_json }}"
|
|
- name: Set default docker user configuration
|
|
when: not docker_config_stat.stat.exists
|
|
set_fact:
|
|
docker_config:
|
|
auths: {}
|
|
- name: Add registry to docker user configuration
|
|
vars:
|
|
new_config:
|
|
auths: |
|
|
{
|
|
"https://index.docker.io/v1/":
|
|
{"auth": "{{ (buildset_registry.username + ":" + buildset_registry.password) | b64encode }}"},
|
|
"{{ buildset_registry.host }}:{{ buildset_registry.port }}":
|
|
{"auth": "{{ (buildset_registry.username + ":" + buildset_registry.password) | b64encode }}"},
|
|
"{{ buildset_registry.push_host }}:{{ buildset_registry.push_port }}":
|
|
{"auth": "{{ (buildset_registry.username + ":" + buildset_registry.password) | b64encode }}"}
|
|
}
|
|
set_fact:
|
|
docker_config: "{{ docker_config | combine(new_config, recursive=True) }}"
|
|
- name: Save docker user configuration
|
|
copy:
|
|
content: "{{ docker_config | to_nice_json }}"
|
|
dest: "~/.docker/config.json"
|
|
mode: 0600
|