r/fluent-bit: Support drop-in configuration files

Fluent Bit supports including configuration fragments from other files
using its `includes` option.  Adding a glob pattern to the default
configuration will allow other roles to supply additional configuration
by creating files in the `/etc/fluent-bit/include` directory.  This
makes composition of configuration significantly easier.

Unfortunately, `fluent-bit` has a quirk in that there must exist at
least one file matching the glob pattern, or it will fail to start.  To
work around this, we must supply an empty fragment.
This commit is contained in:
2025-12-03 22:01:58 -06:00
parent cc288a4ee3
commit 6ad76e4b33
2 changed files with 25 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
fluent_bit_config:
includes:
- /etc/fluent-bit/include/*.yml
service: '{{ fluent_bit_config_service }}'
parsers: '{{ fluent_bit_parsers }}'
multiline_parsers: '{{ fluent_bit_multiline_parsers }}'

View File

@@ -5,6 +5,29 @@
tags:
- install
- name: ensure fluent-bit config include directory exists
file:
path: /etc/fluent-bit/include
owner: root
group: root
mode: u=rwx,go=
state: directory
tags:
- config
# fluent-bit will fail to start if a glob pattern listed in `includes` does not
# match any files. To allow roles to drop additiona configuration files in the
# include directory without modifying the main configuration file, we need to
# have an empty file in the include directory all the time.
- name: ensure fluent-bit empty include file exists
copy:
dest: /etc/fluent-bit/include/_.yml
content: ''
owner: root
group: root
mode: u=rwx,go=
tags:
- config
- name: ensure fluent-bit is configured
copy:
dest: /etc/fluent-bit/fluent-bit.yml