Browse Source

Allowing means to provide custom es config entries with openshift_logging_es_config

Eric Wolinetz 7 years ago
parent
commit
76d5d6b146

+ 2 - 3
roles/openshift_logging_elasticsearch/defaults/main.yml

@@ -50,9 +50,8 @@ openshift_logging_elasticsearch_ops_deployment: false
 
 openshift_logging_elasticsearch_ops_allow_cluster_reader: false
 
-# following can be uncommented to provide values for configmaps -- take care when providing file contents as it may cause your cluster to not operate correctly
-#es_logging_contents:
-#es_config_contents:
+# openshift_logging_es_config is a hash to be merged into the defaults for the elasticsearch.yaml
+openshift_logging_es_config: {}
 
 
 openshift_logging_master_url: "https://kubernetes.default.svc.{{ openshift.common.dns_domain }}"

+ 22 - 0
roles/openshift_logging_elasticsearch/tasks/main.yaml

@@ -239,6 +239,17 @@
       - current_file: "logging.yml"
         new_file: "{{ tempdir }}/elasticsearch-logging.yml"
 
+  - slurp:
+      src: "{{ tempdir }}/elasticsearch.yml"
+    register: _patched_elasticsearch_config
+
+  - copy:
+      content: "{{ config_source | combine(override_config, recursive=True) | to_nice_yaml(indent=2) }}"
+      dest: "{{ tempdir }}/elasticsearch.yml"
+    vars:
+      config_source: "{{ _patched_elasticsearch_config['content'] | b64decode | from_yaml }}"
+      override_config: "{{ openshift_logging_es_config | default({}) | from_yaml }}"
+
   - name: Set ES configmap
     oc_configmap:
       state: present
@@ -271,6 +282,17 @@
       - current_file: "log4j2.properties"
         new_file: "{{ tempdir }}/log4j2.properties"
 
+  - slurp:
+      src: "{{ tempdir }}/elasticsearch.yml"
+    register: _patched_elasticsearch_config
+
+  - copy:
+      content: "{{ config_source | combine(override_config, recursive=True) | to_nice_yaml(indent=2) }}"
+      dest: "{{ tempdir }}/elasticsearch.yml"
+    vars:
+      config_source: "{{ _patched_elasticsearch_config['content'] | b64decode | from_yaml }}"
+      override_config: "{{ openshift_logging_es_config | default({}) | from_yaml }}"
+
   - name: Set ES configmap
     oc_configmap:
       state: present