An Ansible role for installing and configuring Fluent Bit, a fast and flexible log processor and forwarder.
This role installs Fluent Bit from the official repository and configures it to use YAML configuration files instead of the default configuration format. It sets up a systemd service override to use the YAML configuration file and provides configurable service parameters.
The role does not configure any inputs, parsers, outputs, ... it only sets up the service and allows you to manage the Fluent Bit service using Ansible.
You need to provide your own configuration files in the
/etc/fluent-bit/conf.d/
. The suggested layout is described in the
Suggested Layout section below.
- Ansible >= 2.1
- Supported platforms:
- Ubuntu (all versions)
- Debian (all versions)
- systemd-based systems
- Internet connectivity for package installation
Variable | Type | Default | Description |
---|---|---|---|
fluentbit_enabled |
boolean | true |
Enable or disable the Fluent Bit role execution |
All service configuration variables correspond to Fluent Bit's service section parameters.
Variable | Type | Default | Description |
---|---|---|---|
fluentbit_service_flush |
integer | 1 |
Set the flush time in seconds. Collector always tries to flush the records every time period |
fluentbit_service_daemon |
string | "Off" |
Run Fluent Bit as a daemon. Allowed values: On, Off |
fluentbit_service_log_level |
string | "info" |
Set the logging verbosity level. Allowed values: off, error, warn, info, debug, trace |
fluentbit_service_http_server |
string | "off" |
Enable HTTP server for monitoring and metrics. Allowed values: on, off |
fluentbit_service_http_listen |
string | "127.0.0.1" |
Set listening interface for HTTP server when enabled |
fluentbit_service_http_port |
integer | 2020 |
Set TCP port for the HTTP server when enabled |
fluentbit_service_storage_metrics |
string | "on" |
Enable storage layer metrics. Allowed values: on, off |
None.
- hosts: servers
become: yes
roles:
- devopsworks.fluentbit
- hosts: servers
become: yes
vars:
fluentbit_service_log_level: "debug"
fluentbit_service_http_server: "on"
fluentbit_service_http_listen: "0.0.0.0"
fluentbit_service_flush: 5
roles:
- devopsworks.fluentbit
The role creates the following files:
/etc/fluent-bit/fluent-bit.yaml
- Main YAML configuration file/etc/fluent-bit/conf.d/
- Directory for additional configuration files/etc/systemd/system/fluent-bit.service.d/override.conf
- systemd override to use YAML config
You can organize your Fluent Bit configuration files in the
/etc/fluent-bit/conf.d/
directory as follows:
- parsers are prefixed with
2x-<name>
- inputs are prefixed with
3x-<tag>-<input_name>
; note that they must be inside apipeline
block - filters are prefixed with
4x-<tag>-<filter_name>
; since multiple filters are used in sequence for a purpose, use the main (or most used) filter name, the goal is to be descriptive; note that they must be inside apipeline
block - outputs are prefixed with
5x_<tag>-<output_name>
; note that they must be inside apipeline
block - full pipelines are prefixed with
90_
Note that:
- fluent-bit does not support multiple pipelines in a single configuration file, so each pipeline should be in its own file.
- fluent-bit merges all pipelines into one
So the layout looks like:
├── 2x-parsers.yaml
├── 3x-inputs.yaml
├── 4x-filters.yaml
├── 5x-pipeline.yaml
├── 90_output.yaml
└── 90_output2.yaml
The role:
- Installs Fluent Bit from the official repository
- Creates systemd service override to use YAML configuration
- Enables and starts the fluent-bit service
- Provides a restart handler when configuration changes
Run linting checks:
make lint
This runs:
ansible-lint
for Ansible best practicesyamllint
for YAML formattingmarkdownlint
for Markdown files
Run the full test suite with Molecule:
make test
This tests the role against:
- Ubuntu 24.04
- Debian 11
- Debian 12
Clean up test artifacts:
make clean
Platform | Status |
---|---|
Ubuntu 20.04 | ✅ Tested |
Ubuntu 22.04 | ✅ Tested |
Ubuntu 24.04 | ✅ Tested |
Debian 11 | ✅ Tested |
Debian 12 | ✅ Tested |
The role supports the following tags:
fluentbit
- Run all Fluent Bit tasksfluentbit:configure
- Run only configuration tasks
Example usage:
ansible-playbook playbook.yml --tags "fluentbit:configure"
MIT
This role was created by devops.works.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
make test
- Run linting:
make lint
- Submit a pull request
- Add empty dummy configuration file to ensure Fluent Bit starts properly
- Add CLAUDE.md file for enhanced Claude Code development experience
- Fix: Refactor include_tasks syntax for clarity and consistency in fluentbit tasks
- Add ignore_errors conditionals for systemd tasks when running under Molecule/containers
- Configure ansible-lint to skip ignore-errors rule for containerized testing environments
- Improve reliability of role execution in Docker/Podman containers
- Initial release
- Support for Ubuntu and Debian
- YAML configuration support
- systemd service override
- Molecule testing framework
- Fix: Update molecule configuration for improved platform setup
- Fix: Update Fluent Bit handlers and tasks for improved service management and configuration
- Fix: Remove ignore_errors from Fluent Bit service enable task for improved error handling
- Fix: Remove ignore_errors from Fluent Bit handlers and tasks for improved error handling
- Switch molecule from Docker to Podman driver
- Fix Podman molecule tmpfs configuration syntax
- Improve CI Docker setup and configuration