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

logstash: config,patternfile respect $::logstash::ensure #411

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

damonbreeden
Copy link

otherwise if a server has ensure => false but still calls logstash::configfile for any reason the file will try to be created but fail bc /etc/logstash does not exist

e.g. in your private base.pp you say

include logstash
logstash::configfile {
  ...
}

but somewhere in hiera you don't want to install logstash on a cluster so you have
logstash::ensure: absent

otherwise if a server has `ensure => false` but still calls `logstash::configfile` for any reason the file will try to be created but fail bc `/etc/logstash` does not exist
@damonbreeden
Copy link
Author

ping 🙏

@smortex smortex added the bug Something isn't working label Jan 3, 2023
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.

That… looks… reasonably… safe… ? 🙄

/me loves CI

@smortex
Copy link
Member

smortex commented Jan 3, 2023

Wait, we do have CI in this project. I try to trigger it by closing and re-opening it…

@smortex smortex closed this Jan 3, 2023
@smortex smortex reopened this Jan 3, 2023
@@ -42,6 +42,7 @@
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
#
define logstash::configfile (
$ensure = $::logstash::ensure,
Copy link
Member

Choose a reason for hiding this comment

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

If you think this parameter is required, please add some documentation above:

# @param ensure
#   ...

But AFAIAC, i think we do not need this extra parameter and we can directly use logstash::ensure. In this case, this line can be removed, and the two bellow changes are required:

Copy link
Author

Choose a reason for hiding this comment

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

i think that more granularity (with proper default values) is always better
in this case, we had a configfile that was placed by this module, then later i wanted to remove it so i made these changes and specifically called absent

could i have accomplished the same with a file resource? yes ofc! but we place the files in /etc/logstash/conf.d with logstash::configfile so we should be able to remove them the same way

alternatively (or probably?) we could/should manage the entire /etc/logstash/conf.d directory (with purge => true so that no files are leftover

@@ -64,6 +65,7 @@

if($config) {
file { $config_file:
ensure => $ensure,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ensure => $ensure,
ensure => $logstash::ensure,

Copy link
Member

Choose a reason for hiding this comment

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

if there's a $ensure parameter, we should also use it?

@@ -74,6 +76,7 @@
}
elsif($source) {
file { $config_file:
ensure => $ensure,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ensure => $ensure,
ensure => $logstash::ensure,

@@ -20,6 +20,7 @@
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
#
define logstash::patternfile (
$ensure = $::logstash::ensure,
Copy link
Member

Choose a reason for hiding this comment

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

Same, either we need to document this…

@@ -28,7 +29,7 @@
$destination = pick($filename, basename($source))

file { "${logstash::config_dir}/patterns/${destination}":
ensure => file,
ensure => $ensure,
Copy link
Member

Choose a reason for hiding this comment

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

…otherwise:

Suggested change
ensure => $ensure,
ensure => $logstash::ensure,

@bastelfreak
Copy link
Member

@damonbreeden please rebase against our latest master branch to get rid of the merge commit.

@@ -2,6 +2,10 @@
#
# Parameters are mutually exclusive. Only one should be specified.
#
# @param [String] ensure
Copy link
Member

Choose a reason for hiding this comment

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

please don't list the datatype, that's a legacy notation and not required anymore. puppet-strings will parse it out of the code now.

Suggested change
# @param [String] ensure
# @param ensure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants