Blame SOURCES/logging-0002-elasticsearch-output-template.diff

69e14a
From e7f255a64a1ffe83b06e93c944c73b8079f1db3a Mon Sep 17 00:00:00 2001
69e14a
From: Noriko Hosoi <nhosoi@redhat.com>
69e14a
Date: Thu, 10 Sep 2020 17:15:32 -0700
69e14a
Subject: [PATCH 2/7] Fixing a logic bug in elasticsearch output template.
69e14a
69e14a
When evaluated, the retryfailures value was denied by "not", which
69e14a
should not have been. Removing the "not" and adding a test case to
69e14a
tests_files_elasticsearch_use_local_cert.yml.
69e14a
69e14a
(cherry picked from commit 108f06926f7bec929fdfc24ce2fbcfe195078ae2)
69e14a
---
69e14a
 roles/rsyslog/templates/output_elasticsearch.j2  |  2 +-
69e14a
 .../tests_files_elasticsearch_use_local_cert.yml | 16 +++++++++++++---
69e14a
 2 files changed, 14 insertions(+), 4 deletions(-)
69e14a
69e14a
diff --git a/roles/rsyslog/templates/output_elasticsearch.j2 b/roles/rsyslog/templates/output_elasticsearch.j2
69e14a
index c3cd1df..c4db10f 100644
69e14a
--- a/roles/rsyslog/templates/output_elasticsearch.j2
69e14a
+++ b/roles/rsyslog/templates/output_elasticsearch.j2
69e14a
@@ -44,7 +44,7 @@ ruleset(name="{{ item.name }}") {
69e14a
             bulkid="{{ item.bulkid | d("id_template") }}"
69e14a
             dynbulkid="{{ item.dynbulkid | d('on') }}"
69e14a
             allowUnsignedCerts="{{ item.allowUnsignedCerts | d("off") }}"
69e14a
-{% if not item.retryfailures | d(true) %}
69e14a
+{% if item.retryfailures | d(true) %}
69e14a
 {%   if item.retryruleset | d() | length > 0 %}
69e14a
             retryfailures="on"
69e14a
             retryruleset="{{ item.retryruleset }}"
69e14a
diff --git a/tests/tests_files_elasticsearch_use_local_cert.yml b/tests/tests_files_elasticsearch_use_local_cert.yml
69e14a
index 2559ce7..8b1eaa4 100644
69e14a
--- a/tests/tests_files_elasticsearch_use_local_cert.yml
69e14a
+++ b/tests/tests_files_elasticsearch_use_local_cert.yml
69e14a
@@ -44,6 +44,7 @@
69e14a
     __test_ca_cert: /tmp/es-ca.crt
69e14a
     __test_cert: /tmp/es-cert.pem
69e14a
     __test_key: /tmp/es-key.pem
69e14a
+    __test_el: elasticsearch_output
69e14a
 
69e14a
   tasks:
69e14a
     - name: Generate fake key/certs files.
69e14a
@@ -60,13 +61,13 @@
69e14a
     - name: deploy config to send to elasticsearch
69e14a
       vars:
69e14a
         logging_outputs:
69e14a
-          - name: elasticsearch_output
69e14a
+          - name: "{{ __test_el }}"
69e14a
             type: elasticsearch
69e14a
             server_host: logging-es
69e14a
             server_port: 9200
69e14a
             index_prefix: project.
69e14a
             input_type: ovirt
69e14a
-            retryfailures: false
69e14a
+            retryfailures: on
69e14a
             ca_cert_src: "{{ __test_ca_cert }}"
69e14a
             cert_src: "{{ __test_cert }}"
69e14a
             private_key_src: "{{ __test_key }}"
69e14a
@@ -77,7 +78,7 @@
69e14a
         logging_flows:
69e14a
           - name: flow_0
69e14a
             inputs: [files_input]
69e14a
-            outputs: [elasticsearch_output, elasticsearch_output_ops]
69e14a
+            outputs: "[{{ __test_el }}]"
69e14a
       include_role:
69e14a
         name: linux-system-roles.logging
69e14a
 
69e14a
@@ -119,3 +120,12 @@
69e14a
         - mycert: "{{ __test_cert }}"
69e14a
         - myprivkey: "{{ __test_key }}"
69e14a
       changed_when: false
69e14a
+
69e14a
+    - name: Check retryfailures in {{ __test_outputfiles_conf }}
69e14a
+      command: /bin/grep 'retryfailures="on"' {{ __test_outputfiles_conf }}
69e14a
+      changed_when: false
69e14a
+
69e14a
+    - name: Check retryruleset in {{ __test_outputfiles_conf }}
69e14a
+      command: /bin/grep 'retryruleset="{{ __test_el }}"' {{ __test_outputfiles_conf }}
69e14a
+      changed_when: false
69e14a
+
69e14a
-- 
69e14a
2.26.2
69e14a