Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 503a749

Browse files
committed
Added elasticsearch_port to the default. Support clusters in the config. [ci skip]
1 parent 92c3dd2 commit 503a749

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

roles/td_agent/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
elasticsearch_port: 9200

roles/td_agent/tasks/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
- name: configure td-agent in /etc/td-agent/td-agent.conf
4242
template: src=td-agent.conf dest=/etc/td-agent/td-agent.conf owner=root group=root mode=0644
43-
tags: tdagent
43+
tags:
44+
- tdagent
45+
- configuration
4446
notify:
4547
- restart td-agent

roles/td_agent/templates/td-agent.conf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717
</source>
1818

1919
<match syslog.**>
20+
2021
type elasticsearch
2122
logstash_format true
22-
host {{ hostvars[groups["monitors"][0]]["ansible_default_ipv4"]["address"] }}
23-
</match>
23+
{% if groups["elasticsearch"]|length == 1 %}
24+
host {{ hostvars[groups["elasticsearch"][0]]["ansible_default_ipv4"]["address"] }}
25+
port {{ elasticsearch_port }}
26+
{% else %}
27+
hosts {% for host in groups['elasticsearch'] %}{{ hostvars[host]["ansible_default_ipv4"]["address"] }}:{{ elasticsearch_port }}{% if not loop.last %},{% endif %}{% endfor %}
28+
{% endif %}
29+
30+
</match>

0 commit comments

Comments
 (0)