summaryrefslogtreecommitdiffstats
path: root/ansible/roles/docker
diff options
context:
space:
mode:
authorPetr Ospalý <p.ospaly@partner.samsung.com>2019-03-04 06:56:33 +0100
committerPetr Ospalý <p.ospaly@partner.samsung.com>2019-03-18 18:38:29 +0100
commitf604d490d97e3b580029bd4cfade324174555dc2 (patch)
tree6d76ae8eebfb0242c41b8d5b576c796713a83435 /ansible/roles/docker
parentc3bdc3210bbaf715805059bfef9b182051b3aa0c (diff)
Add default logging settings for docker
- Default configuration of logging for docker daemon. - New ansible module for generic handling of JSON files. - New setting in ansible.cfg: jinja2_native = True To preserve double-quotes in json values (OOM-1698). Issue-ID: OOM-1681 Change-Id: I8f8e19ebc290fd48a63146e96f418b98344e4433 Signed-off-by: Petr Ospalý <p.ospaly@partner.samsung.com>
Diffstat (limited to 'ansible/roles/docker')
-rw-r--r--ansible/roles/docker/defaults/main.yml4
-rw-r--r--ansible/roles/docker/tasks/main.yml14
2 files changed, 16 insertions, 2 deletions
diff --git a/ansible/roles/docker/defaults/main.yml b/ansible/roles/docker/defaults/main.yml
new file mode 100644
index 00000000..1922f64b
--- /dev/null
+++ b/ansible/roles/docker/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+docker:
+ log_max_size: 100m
+ log_max_file: 3
diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml
index 09e790a4..16b7002f 100644
--- a/ansible/roles/docker/tasks/main.yml
+++ b/ansible/roles/docker/tasks/main.yml
@@ -16,11 +16,21 @@
path: /etc/docker
state: directory
+- name: Setup docker container logging settings
+ json_mod:
+ path: /etc/docker/daemon.json
+ key: '' # the whole JSON document per https://tools.ietf.org/html/rfc6901
+ # "value" must be wrapped in single quote "'" with extra space in front of "{" (ansible workaround)
+ # reference: https://stackoverflow.com/questions/31969872
+ value: ' { "log-driver": "json-file", "log-opts": { "max-size": "{{ docker.log_max_size }}", "max-file": "{{ docker.log_max_file }}" } }'
+
- name: Setup docker dns settings
- json_add:
+ json_mod:
path: /etc/docker/daemon.json
key: dns
- value: "{{ hostvars[groups.infrastructure[0]].cluster_ip }}"
+ # "value" must be wrapped in single quote "'" with extra space in front of "[" (ansible workaround)
+ # reference: https://stackoverflow.com/questions/31969872
+ value: ' [ "{{ hostvars[groups.infrastructure[0]].cluster_ip }}" ]'
notify:
- Restart Docker