zuul-jobs/roles/ensure-docker/tasks/docker-setup.yaml
vass c80b593fb6 Rename install-docker to ensure-docker for consistency
The old role will be kept and include ensure-docker for backwards compatability.

Change-Id: Icb76a954b04631c405b09eb54343fd852a511b83
2020-04-04 15:41:29 -04:00

49 lines
1.4 KiB
YAML

---
- name: Ensure "docker" group exists
group:
name: "{{ docker_group }}"
state: present
- name: Add user to docker group
user:
name: "{{ ansible_user }}"
groups:
- "{{ docker_group }}"
append: yes
- name: Update docker daemon configuration
when: docker_userland_proxy is defined
block:
- name: Check if docker daemon configuration exists
stat:
path: /etc/docker/daemon.json
register: docker_config_stat
- name: Load docker daemon configuration
when: docker_config_stat.stat.exists
slurp:
path: /etc/docker/daemon.json
register: docker_config
- name: Parse docker daemon configuration
when: docker_config_stat.stat.exists
set_fact:
docker_config: "{{ docker_config.content | b64decode | from_json }}"
- name: Set default docker daemon configuration
when: not docker_config_stat.stat.exists
set_fact:
docker_config: {}
- name: Add registry to docker daemon configuration
vars:
new_config:
userland-proxy: "{{ docker_userland_proxy }}"
set_fact:
docker_config: "{{ docker_config | combine(new_config) }}"
- name: Save docker daemon configuration
copy:
content: "{{ docker_config | to_nice_json }}"
dest: /etc/docker/daemon.json
become: true
- name: Reset ssh connection to pick up docker group
meta: reset_connection