Bläddra i källkod

container-engine: log-opts is a dictionary in the daemon.json file

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Giuseppe Scrivano 7 år sedan
förälder
incheckning
9c29b47f78

+ 8 - 0
filter_plugins/oo_filters.py

@@ -375,6 +375,13 @@ def oo_split(string, separator=','):
     return string.split(separator)
 
 
+def oo_list_to_dict(lst, separator='='):
+    """ This converts a list of ["k=v"] to a dictionary {k: v}.
+    """
+    kvs = [i.split(separator) for i in lst]
+    return {k: v for k, v in kvs}
+
+
 def oo_haproxy_backend_masters(hosts, port):
     """ This takes an array of dicts and returns an array of dicts
         to be used as a backend for the haproxy role
@@ -969,6 +976,7 @@ class FilterModule(object):
             "oo_combine_dict": oo_combine_dict,
             "oo_dict_to_list_of_dict": oo_dict_to_list_of_dict,
             "oo_split": oo_split,
+            "oo_list_to_dict": oo_list_to_dict,
             "oo_filter_list": oo_filter_list,
             "oo_parse_heat_stack_outputs": oo_parse_heat_stack_outputs,
             "oo_parse_named_certificates": oo_parse_named_certificates,

+ 1 - 0
roles/container_runtime/defaults/main.yml

@@ -59,6 +59,7 @@ docker_default_storage_path: /var/lib/docker
 # Set local versions of facts that must be in json format for container-daemon.json
 # NOTE: When jinja2.9+ is used the container-daemon.json file can move to using tojson
 l_docker_log_options: "{{ l2_docker_log_options | to_json }}"
+l_docker_log_options_dict: "{{ l2_docker_log_options | oo_list_to_dict | to_json }}"
 l_docker_additional_registries: "{{ l2_docker_additional_registries | to_json }}"
 l_docker_blocked_registries: "{{ l2_docker_blocked_registries | to_json }}"
 l_docker_insecure_registries: "{{ l2_docker_insecure_registries | to_json }}"

+ 1 - 1
roles/container_runtime/templates/daemon.json

@@ -8,7 +8,7 @@
 {% if openshift_docker_log_driver is defined  %}
     "log-driver": "{{ openshift_docker_log_driver }}",
 {%- endif %}
-    "log-opts": {{ l_docker_log_options }},
+    "log-opts": {{ l_docker_log_options_dict }},
     "runtimes": {
 	"oci": {
 	    "path": "/usr/libexec/docker/docker-runc-current"