By default, rsyslog_receiver is undefined (because it's commented out in defaults/main.yml) and its value is ignored if it is set, since all references to it (in templates/advanced_rsyslog.conf.j2, templates/legacy_rsyslog.conf.j2, etc.) only check whether it's defined ("{{ '' if rsyslog_receiver is defined else '#' }}", etc.).
If defined, it does need to be a boolean (because of the checks in tasks/assert.yml), but the role's behavior is unintuitive, since setting it to nodoes configure the server to receive logs (just like setting it to yes).
Proposed fix
Make rsyslog_receiver required (always defined) by setting a default value (no) in defaults/main.yml and removing the when conditional for its type checking in tasks/assert.yml
Instead of checking for if rsyslog_receiver is defined, check for if rsyslog_receiver, which will behave as expected once the value is always defined and set to boolean yes or no
https://github.com/robertdebock/ansible-role-rsyslog/blob/fadc2a2dcd601e80e1f5afbf05727e50201c1c97/defaults/main.yml#L6
https://github.com/robertdebock/ansible-role-rsyslog/blob/fadc2a2dcd601e80e1f5afbf05727e50201c1c97/templates/advanced_rsyslog.conf.j2#L31
Describe the bug
By default,
rsyslog_receiver
is undefined (because it's commented out indefaults/main.yml
) and its value is ignored if it is set, since all references to it (intemplates/advanced_rsyslog.conf.j2
,templates/legacy_rsyslog.conf.j2
, etc.) only check whether it's defined ("{{ '' if rsyslog_receiver is defined else '#' }}
", etc.).If defined, it does need to be a boolean (because of the checks in
tasks/assert.yml
), but the role's behavior is unintuitive, since setting it tono
does configure the server to receive logs (just like setting it toyes
).Proposed fix
rsyslog_receiver
required (always defined) by setting a default value (no
) indefaults/main.yml
and removing thewhen
conditional for its type checking intasks/assert.yml
if rsyslog_receiver is defined
, check forif rsyslog_receiver
, which will behave as expected once the value is always defined and set to booleanyes
orno