diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml
index 946f0c0852..b33217de3f 100644
--- a/ansible/roles/common/tasks/config.yml
+++ b/ansible/roles/common/tasks/config.yml
@@ -35,11 +35,15 @@
- name: Copying over fluentd ouput config files
template:
- src: "conf/output/{{ item }}.conf.j2"
- dest: "{{ node_config_directory }}/fluentd/output/{{ item }}.conf"
+ src: "conf/output/{{ item.name }}.conf.j2"
+ dest: "{{ node_config_directory }}/fluentd/output/{{ item.name }}.conf"
+ when: item.enabled | bool
with_items:
- - "00-local"
- - "01-es"
+ - name: "00-local"
+ enabled: true
+ - name: "01-es"
+ enabled: "{{ enable_elasticsearch }}"
+
- name: Copying over fluentd format config files
template:
src: "conf/format/{{ item }}.conf.j2"
@@ -48,7 +52,7 @@
- "apache_access"
- "wsgi_access"
- "wsgi_python"
-
+
- name: Copying over fluentd filter config files
template:
src: "conf/filter/{{ item }}.conf.j2"
diff --git a/ansible/roles/common/templates/conf/output/00-local.conf.j2 b/ansible/roles/common/templates/conf/output/00-local.conf.j2
index 650f5730ba..0b2f470169 100644
--- a/ansible/roles/common/templates/conf/output/00-local.conf.j2
+++ b/ansible/roles/common/templates/conf/output/00-local.conf.j2
@@ -8,6 +8,7 @@
append true
compress gzip
+{% if enable_elasticsearch | bool %}
type elasticsearch
host {{ kolla_external_vip_address }}
@@ -16,6 +17,7 @@
logstash_prefix flog
flush_interval 15s
+{% endif %}
@@ -30,6 +32,7 @@
append true
compress gzip
+{% if enable_elasticsearch | bool %}
type elasticsearch
host {{ kolla_external_vip_address }}
@@ -38,4 +41,5 @@
logstash_prefix flog
flush_interval 15s
+{% endif %}
diff --git a/ansible/roles/common/templates/fluentd.json.j2 b/ansible/roles/common/templates/fluentd.json.j2
index a4e01142ec..3451c265fa 100644
--- a/ansible/roles/common/templates/fluentd.json.j2
+++ b/ansible/roles/common/templates/fluentd.json.j2
@@ -60,13 +60,13 @@
"dest": "/etc/td-agent/format/wsgi_python.conf",
"owner": "td-agent",
"perm": "0600"
- },
+ },{% if enable_elasticsearch | bool %}
{
"source": "{{ container_config_directory }}/output/01-es.conf",
"dest": "/etc/td-agent/output/01-es.conf",
"owner": "td-agent",
"perm": "0600"
- },
+ },{% endif %}
{
"source": "{{ container_config_directory }}/output/00-local.conf",
"dest": "/etc/td-agent/output/00-local.conf",