2 Commits

Author SHA1 Message Date
Rainer Gerhards
e8fa2034fe feat: add YAML as an alternative configuration format
rsyslog now accepts .yaml / .yml files as a full alternative to
RainerScript configuration.  Whenever a .yaml or .yml file is
referenced (e.g. via $IncludeConfig or as the main config), it is
routed through the new yamlconf loader instead of the bison/flex
parser.  RainerScript and YAML configurations may coexist.

Supported top-level sections
  global:          global settings
  main_queue:      main queue settings
  modules:         module loading (load:, params:)
  inputs:          input objects  templates:       string, subtree, plugin, and list templates
                   (including all property/constant modifiers)
  rulesets:        rulesets with optional script: block (raw
                   RainerScript), filter/action shortcut (if:/then:),
                   and the full statements: block:
                     action:, set:, unset:, call:, call_indirect:,
                     foreach:, if:, stop:, continue:,
                     reload_lookup_table:
  outputs:         output objects (top-level convenience alias)
  include:         recursive includes (.yaml processed immediately;
                   .conf files pushed to LIFO stack in reverse order
                   for correct document-order processing)

Implementation notes
  - Thin front-end over existing cnfobj/nvlst/cnfDoObj() machinery;
    all parameter validation happens downstream unchanged.
  - Script blocks synthesised as RainerScript strings and injected via
    cnfAddConfigBuffer() (requires two trailing NUL bytes).
  - YAML -> YAML includes are synchronous recursive calls;
    YAML -> .conf includes use the flex buffer stack.
  - Mixed include lists (.yaml + .conf) emit a warning because strict
    document order cannot be preserved across the two mechanisms.
  - Built conditionally: --with-libyaml / HAVE_LIBYAML.

Tests
  19 new shell tests cover: basic config, modules, inputs, templates
  (string/subtree/list with modifiers), rulesets with script/filter/
  statements blocks, stop/continue, set/unset, foreach, call,
  call_indirect, reload_lookup_table, includes, error handling.

Documentation
  doc/source/configuration/yaml_config.rst  (new reference page)
  Inline comments in yamlconf.c explain all invariants and non-obvious
  design choices (es_getBufAddr non-null-termination, LIFO stack
  ordering, cnfAddConfigBuffer double-NUL requirement, etc.)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:41:37 +01:00
Rainer Gerhards
1cc162b2e1 feat: add YAML as an alternative configuration format
rsyslog now accepts .yaml/.yml files as configuration files
in addition to RainerScript (.conf). The format is triggered
automatically based on file extension, both for the main config
file (-f flag) and for include() directives.

Architecture:
- New runtime/yamlconf.c (libyaml event-based parser) builds the
  same cnfobj+nvlst structures that the bison parser produces and
  calls cnfDoObj() for each block.
- Ruleset script: keys are synthesised into a complete RainerScript
  ruleset(name=...) { ... } block and pushed onto the flex buffer
  stack so the existing lex/bison pipeline handles all filter
  expressions and statements unchanged.
- routing in rsconf.c::load() and cnfDoInclude() detects .yaml/.yml
  by extension and delegates to yamlconf_load().
- cnfHasPendingBuffers() (new) lets rsconf.c flush queued script
  buffers after YAML-as-main-config loading.
- Guarded by #ifdef HAVE_LIBYAML throughout; graceful error when
  libyaml is absent.

Schema (top-level YAML keys):
  global, modules, inputs, templates, rulesets, mainqueue,
  include, parser, lookup_table, dyn_stats, ratelimit, timezone

Parameter names are identical to RainerScript; all type coercion
and validation is reused via nvlstGetParams() unchanged.

Tests: yaml-basic, yaml-include, yaml-ruleset-script, yaml-error
Documentation: doc/source/configuration/yaml_config.rst

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-26 09:19:48 +01:00