Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boolean variable to change behavior of multi-line actions in conf… #204

Closed

Conversation

bschonec
Copy link
Contributor

Added a boolean variable to control the multi-line behavior of the action module. If rsyslog::dont_linebreak_actions == TRUE then all the options in the action will be on a single line.

This behavior might be necessary if you have CIS or STIG scans on your /etc/rsyslog.d configuration files that are looking for settings on a single line such as:

^\s*([^#]+\s+)?action\(([^#]+\s+)?\btarget="?[^#"]+"?\b
and

^\s*\*\.\*\s+@
These regexs will fail even if the configuration is correct but spans multiple lines.

Copy link
Member

@smortex smortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a user of the module so only reporting style issues.

data/common.yaml Outdated
@@ -26,6 +26,7 @@ rsyslog::parser_priority: 45
rsyslog::template_priority: 50
rsyslog::filter_priority: 55
rsyslog::action_priority: 60
rsyslog::dont_linebreak_actions: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add default value to Hiera if they are not changed from one OS to another. This prevent puppet-string from displaying default-values when generating the module REFERENCE file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know this. Thanks for the explanation. Wouldn't it be prudent, then to apply this policy to all of the pre-existing variables in common.yaml?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it is a good idea, submitting this is a follow-up PR is fine.

manifests/init.pp Outdated Show resolved Hide resolved
templates/action.epp Outdated Show resolved Hide resolved
templates/action.epp Outdated Show resolved Hide resolved
@smortex
Copy link
Member

smortex commented Sep 15, 2023

REFERENCE.md is outdated

Please update REFERENCE.md with

$ bundle exec rake strings:generate:reference

Add it to the PR and CI should continue.

@bschonec
Copy link
Contributor Author

@smortex, I updated REFERENCE.md as you suggested but still there are errors.

@smortex
Copy link
Member

smortex commented Sep 15, 2023

It still show "REFERENCE.md is outdated". Maybe your bundle is outdated? I run the following and it passed:

bundle update
bundle exec rake strings:generate:reference
git add REFERENCE.md
git commit -m 'Regenerate REFERENCE.md'
git push

@bschonec
Copy link
Contributor Author

It still show "REFERENCE.md is outdated". Maybe your bundle is outdated? I run the following and it passed:

bundle update
bundle exec rake strings:generate:reference
git add REFERENCE.md
git commit -m 'Regenerate REFERENCE.md'
git push

Perhaps I'm misunderstanding but the tests are not passing.

@@ -3,17 +3,19 @@
String $target,
String $confdir,
String $type,
Boolean $dont_linebreak_actions = $rsyslog::dont_linebreak_actions,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering a catalog with:

rsyslog::component::action { 'foo':
  # ...
}

this will fail because the rsyslog was not included (it is included on line 10, but the parameter default value need it before that code is run).

The following would work:

include rsyslog

rsyslog::component::action { 'foo':
  # ...
}

The test suite probably need to be adjusted to ensure the main class of the module is included before testing the rsyslog::component::action class:

https://rspec-puppet.com/documentation/defined_types/#specifying-code-to-include-before

@bschonec bschonec force-pushed the single_line_action_configuration branch 4 times, most recently from 0ddac64 to 355d76b Compare September 18, 2023 13:52
@bschonec bschonec force-pushed the single_line_action_configuration branch from 355d76b to a71dac3 Compare September 18, 2023 14:06
@bschonec bschonec closed this Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants