From 58cf603ce7120de2be1ba069805c754f3c6c50dc Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 30 Jan 2019 13:53:46 +0000 Subject: [PATCH] Make install-docker compatible with centos Allow custom docker_group which is needed on CentOS when use_upstream_docker: false as is value is 'dockeroot'. Assures that docker service is started, which is not always true with all distributions. Validates that we can talk with docker at the end. Change-Id: I993c4ac35055a2a18b5b0fb32c8b230e04b7eb87 --- roles/install-docker/defaults/main.yaml | 1 + roles/install-docker/tasks/main.yaml | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/roles/install-docker/defaults/main.yaml b/roles/install-docker/defaults/main.yaml index 635168018..bef4fbdef 100644 --- a/roles/install-docker/defaults/main.yaml +++ b/roles/install-docker/defaults/main.yaml @@ -1,4 +1,5 @@ use_upstream_docker: True +docker_group: docker docker_update_channel: stable ubuntu_gpg_key: | -----BEGIN PGP PUBLIC KEY BLOCK----- diff --git a/roles/install-docker/tasks/main.yaml b/roles/install-docker/tasks/main.yaml index 875d7603b..d0da85bac 100644 --- a/roles/install-docker/tasks/main.yaml +++ b/roles/install-docker/tasks/main.yaml @@ -32,8 +32,26 @@ user: name: "{{ ansible_user }}" groups: - - docker + - "{{ docker_group }}" append: yes -- name: reset ssh connection to pick up docker group +- name: Assure docker service is running + become: yes + service: + name: docker + enabled: yes + state: started + +- name: Correct group ownership on docker sock + become: yes + file: + path: /var/run/docker.sock + group: "{{ docker_group }}" + +- name: Reset ssh connection to pick up docker group meta: reset_connection + +- name: Validate ability to talk with docker + command: docker ps + args: + warn: no