Skip to content

Commit

Permalink
Add ensure parameter to pipeline resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Cabezas committed Jul 24, 2023
1 parent aafdaa3 commit 1884cdf
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions manifests/pipeline.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
# }
# @see https://docs.fluentbit.io/manual/administration/configuring-fluent-bit/yaml/configuration-file#config_pipeline
#
# @param ensure Write configuration to disk or not
# @param type Defines the pipeline type to be configured
# @param plugin_name fluent-bit plugin name to be used
# @param order Order to be applied to concat::fragment
# @param properties Hash of rest of properties needed to configure the pipeline-plugin
define fluentbit::pipeline (
Enum['input','filter','output'] $type,
String[1] $plugin_name,
Enum['present','absent'] $ensure = 'present',
String[1] $order = '10',
Hash[String, Any] $properties = {},
) {
Expand Down Expand Up @@ -51,7 +53,7 @@
if $type == 'filter' and $plugin_name == 'lua' and $properties['code'] {
# Catch 'code' property for lua scripts and write it to disk
file { "${fluentbit::config::scripts_dir}/${title}.lua":
ensure => present,
ensure => $ensure,
mode => $fluentbit::config_file_mode,
content => $properties['code'],
notify => Service[$fluentbit::service_name],
Expand All @@ -64,22 +66,24 @@
$script_settings = {}
}

concat::fragment { "fragment-${title}":
target => "${fluentbit::config::plugin_dir}/${type}s.conf",
content => epp('fluentbit/pipeline.conf.epp',
{
name => $plugin_name,
type => $type,
properties => merge(
$db_settings,
{
alias => $title,
},
$properties,
$script_settings,
$upstream_settings,
)
}
),
if $ensure == 'present' {
concat::fragment { "fragment-${title}":
target => "${fluentbit::config::plugin_dir}/${type}s.conf",
content => epp('fluentbit/pipeline.conf.epp',
{
name => $plugin_name,
type => $type,
properties => merge(
$db_settings,
{
alias => $title,
},
$properties,
$script_settings,
$upstream_settings,
)
}
),
}
}
}

0 comments on commit 1884cdf

Please sign in to comment.