From 7e1c66c6df7b3289504bd8a93dcfa90b405e8174 Mon Sep 17 00:00:00 2001 From: Hannes Schaller Date: Tue, 5 Nov 2024 12:31:51 +0100 Subject: [PATCH 1/2] add ability to use multiple config files --- manifests/init.pp | 4 ++++ spec/classes/otelcol_spec.rb | 11 +++++++++++ templates/environment.conf.erb | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 25fa850..c82893f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -20,6 +20,9 @@ # group of config_file # @param config_file_mode # mode of config_file +# @param configs +# additional config files or resources to add. Since this can be environment variables, http urls or files +# you are required to ensure the existence of a file! # @param receivers # Hash for receivers config # @param processors @@ -61,6 +64,7 @@ String $config_file_owner = 'root', String $config_file_group = 'root', Stdlib::Filemode $config_file_mode = '0644', + Array[String] $configs = [], Hash[String, Hash] $receivers = {}, Hash[String, Hash] $processors = {}, Hash[String, Hash] $exporters = {}, diff --git a/spec/classes/otelcol_spec.rb b/spec/classes/otelcol_spec.rb index b435dd7..1302fa9 100644 --- a/spec/classes/otelcol_spec.rb +++ b/spec/classes/otelcol_spec.rb @@ -145,6 +145,17 @@ } end + context 'with configs' do + let :params do + { + configs: ['customconfig.yaml', 'env:MY_CONFIG_IN_AN_ENVVAR', 'https://server/config.yaml', '"yaml:exporters::debug::verbosity: normal"'] + } + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_file('otelcol-environment').with_content(%r{--config=/etc/otelcol/config.yaml --config=customconfig.yaml --config=env:MY_CONFIG_IN_AN_ENVVAR --config=https://server/config.yaml --config="yaml:exporters::debug::verbosity: normal"}) } + end + context 'with config_file owner' do let :params do { diff --git a/templates/environment.conf.erb b/templates/environment.conf.erb index 3d5803e..df8ed12 100644 --- a/templates/environment.conf.erb +++ b/templates/environment.conf.erb @@ -3,4 +3,4 @@ # Command-line options for the <%= scope.lookupvar('otelcol::package_name')%> service. # Run `/usr/bin/<%= scope.lookupvar('otelcol::package_name') %> --help` to see all available options. -OTELCOL_OPTIONS="<%= scope.lookupvar('otelcol::run_options')%> --config=<%= scope.lookupvar('otelcol::config_file')%>" \ No newline at end of file +OTELCOL_OPTIONS="<%= scope.lookupvar('otelcol::run_options')%> --config=<%= scope.lookupvar('otelcol::config_file') %><% unless scope.lookupvar('otelcol::configs').empty? -%> --config=<%= scope.lookupvar('otelcol::configs').join(' --config=') %><% end -%>" From 0b33285ff0c8752a052ffde0660c5f11bd4d5ab6 Mon Sep 17 00:00:00 2001 From: Hannes Schaller Date: Tue, 5 Nov 2024 12:35:55 +0100 Subject: [PATCH 2/2] add ability to use multiple config files --- REFERENCE.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/REFERENCE.md b/REFERENCE.md index 0e91581..b790216 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -54,6 +54,7 @@ The following parameters are available in the `otelcol` class: * [`config_file_owner`](#-otelcol--config_file_owner) * [`config_file_group`](#-otelcol--config_file_group) * [`config_file_mode`](#-otelcol--config_file_mode) +* [`configs`](#-otelcol--configs) * [`receivers`](#-otelcol--receivers) * [`processors`](#-otelcol--processors) * [`exporters`](#-otelcol--exporters) @@ -150,6 +151,15 @@ mode of config_file Default value: `'0644'` +##### `configs` + +Data type: `Array[String]` + +additional config files or resources to add. Since this can be environment variables, http urls or files +you are required to ensure the existence of a file! + +Default value: `[]` + ##### `receivers` Data type: `Hash[String, Hash]`