2f2d6ce3f7
This exercises the intermediate and buildset registry roles. Change-Id: Ic0da2d6b48a7b9f9b616033c70db471ba98181b4
40 lines
1.2 KiB
YAML
40 lines
1.2 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: |
|
|
{
|
|
"localhost:5000":
|
|
{"auth": "{{ (intermediate_registry.username + ":" + intermediate_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
|