From c289d282af6a0eb1fa0881823b89bc96eb2eee4d Mon Sep 17 00:00:00 2001 From: Damon Breeden Date: Fri, 6 May 2022 19:40:11 +0000 Subject: [PATCH 1/2] logstash: config,patternfile respect `$::logstash::ensure` 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 --- manifests/configfile.pp | 3 +++ manifests/patternfile.pp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/configfile.pp b/manifests/configfile.pp index eb8c9719..1334ee89 100644 --- a/manifests/configfile.pp +++ b/manifests/configfile.pp @@ -42,6 +42,7 @@ # @author https://github.com/elastic/puppet-logstash/graphs/contributors # define logstash::configfile ( + $ensure = $::logstash::ensure, $content = undef, $source = undef, $template = undef, @@ -64,6 +65,7 @@ if($config) { file { $config_file: + ensure => $ensure, content => $config, owner => $owner, group => $group, @@ -74,6 +76,7 @@ } elsif($source) { file { $config_file: + ensure => $ensure, source => $source, owner => $owner, group => $group, diff --git a/manifests/patternfile.pp b/manifests/patternfile.pp index 4490ff15..fe85b53a 100644 --- a/manifests/patternfile.pp +++ b/manifests/patternfile.pp @@ -20,6 +20,7 @@ # @author https://github.com/elastic/puppet-logstash/graphs/contributors # define logstash::patternfile ( + $ensure = $::logstash::ensure, Pattern[/^(puppet|file):\/\//] $source = undef, Optional[String[1]] $filename = undef, ) { @@ -28,7 +29,7 @@ $destination = pick($filename, basename($source)) file { "${logstash::config_dir}/patterns/${destination}": - ensure => file, + ensure => $ensure, source => $source, owner => 'root', group => $logstash::logstash_group, From b6b4b631752c610fa27976935fdfeee2e8542f41 Mon Sep 17 00:00:00 2001 From: Damon Breeden Date: Fri, 6 Jan 2023 22:20:58 +0000 Subject: [PATCH 2/2] logstash: configfile: document `ensure` param, fix lint, constrain its values --- manifests/configfile.pp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/configfile.pp b/manifests/configfile.pp index 1334ee89..c903e64d 100644 --- a/manifests/configfile.pp +++ b/manifests/configfile.pp @@ -2,6 +2,10 @@ # # Parameters are mutually exclusive. Only one should be specified. # +# @param [String] ensure +# Ensure the file is either [`present`,`absent`]. +# Useful if you want to place the file on some servers but specifically not on (or remove from) other servers +# # @param [String] content # Literal content to be placed in the file. # @@ -42,7 +46,7 @@ # @author https://github.com/elastic/puppet-logstash/graphs/contributors # define logstash::configfile ( - $ensure = $::logstash::ensure, + Enum['present', 'absent'] $ensure = $logstash::ensure, $content = undef, $source = undef, $template = undef,