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>
diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml
index 09e790a..16b7002 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