Skip to content

Instantly share code, notes, and snippets.

@fopina
Created July 9, 2019 23:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fopina/c0439fa29bb7f3fa541a2d81a3f4a1e7 to your computer and use it in GitHub Desktop.
Save fopina/c0439fa29bb7f3fa541a2d81a3f4a1e7 to your computer and use it in GitHub Desktop.
fluentbit ansible role
---
- name: Restart Fluentbit
service:
name: td-agent-bit
enabled: true
state: restarted
- name: Required variable check
fail:
msg: "both fluentbit_inputs and fluentbit_outputs variables are required"
when: fluentbit_inputs is not defined or fluentbit_outputs is not defined
- name: add fluentbit apt key
apt_key:
url: https://packages.fluentbit.io/fluentbit.key
state: present
- apt_repository:
repo: deb https://packages.fluentbit.io/{{ ansible_lsb.id | lower }}/{{ ansible_lsb.codename }} {{ ansible_lsb.codename }} main
state: present
filename: fluentbit
when: ansible_lsb.codename in ('stretch', 'jessie') and ansible_lsb.id in ('Debian', 'Raspbian')
- name: Install td-agent-bit
apt:
name: td-agent-bit
notify: Restart Fluentbit
- name: generate td-agent-bit config
template:
src: td-agent-bit.conf.j2
dest: /etc/td-agent-bit/td-agent-bit.conf
notify: Restart Fluentbit
[SERVICE]
Flush 5
Daemon Off
Log_Level info
Parsers_File parsers.conf
Plugins_File plugins.conf
HTTP_Server Off
HTTP_Listen 0.0.0.0
HTTP_Port 2020
{% for input in fluentbit_inputs %}
{% for input_name, input_props in input.items() %}
[INPUT]
Name {{ input_name }}
{% for prop in input_props %}
{% for pk, pv in prop.items() %}
{{ pk }} {{ pv }}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% if fluentbit_filters is defined %}
{% for filter in fluentbit_filters %}
{% for filter_name, filter_props in filter.items() %}
[FILTER]
Name {{ filter_name }}
{% for prop in filter_props %}
{% for pk, pv in prop.items() %}
{{ pk }} {{ pv }}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
{% for output in fluentbit_outputs %}
{% for output_name, output_props in output.items() %}
[OUTPUT]
Name {{ output_name }}
{% for prop in output_props %}
{% for pk, pv in prop.items() %}
{{ pk }} {{ pv }}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment