From 46989a520dbf1eb9d460c184973ac4f3232782f0 Mon Sep 17 00:00:00 2001
From: Vamsi Savaram <vamsi.savaram@gmail.com>
Date: Sun, 5 Apr 2020 02:38:32 +0000
Subject: [PATCH] Gather container logs in check pipeline

This patch configures docker daemon to use
journald logging driver

Relates-To: #89

Change-Id: I2e3c4df06163caa032d2d9b7a2032123d311915a
---
 roles/docker-install/defaults/main.yaml | 11 +++++++++++
 roles/docker-install/tasks/main.yaml    | 13 +++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/roles/docker-install/defaults/main.yaml b/roles/docker-install/defaults/main.yaml
index 455091742..623143cd7 100644
--- a/roles/docker-install/defaults/main.yaml
+++ b/roles/docker-install/defaults/main.yaml
@@ -10,6 +10,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+docker_config_path: "/etc/docker"
+
+docker_config_log_driver: "journald"
+docker_config_log_opts: {}
+
+docker_config: |
+  {
+    "log-driver": "{{ docker_config_log_driver }}",
+    "log-opts": {{ docker_config_log_opts | to_json }}
+  }
+
 proxy:
   enabled: false
   http:
diff --git a/roles/docker-install/tasks/main.yaml b/roles/docker-install/tasks/main.yaml
index 3ac80cbb3..98d9c99c6 100644
--- a/roles/docker-install/tasks/main.yaml
+++ b/roles/docker-install/tasks/main.yaml
@@ -62,6 +62,19 @@
   when: proxy.enabled|bool == true
   become: true
 
+- name: Create docker directory
+  file:
+    path: "{{ docker_config_path }}"
+    state: directory
+    mode: '0755'
+  become: true
+
+- name: Save docker daemon configuration
+  copy:
+    content: "{{ docker_config | to_nice_json }}"
+    dest: "{{ docker_config_path }}/daemon.json"
+  become: true
+
 - name: Start docker
   become: true
   systemd: