Skip to content

Commit

Permalink
Merge pull request #644 from Pigueiras/fix_webconfig
Browse files Browse the repository at this point in the history
Adapt web.config.file option for node_exporter versions higher than 1.5.0
  • Loading branch information
bastelfreak authored Jan 25, 2023
2 parents 6661bdf + 5ca1475 commit 1fb07b7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
6 changes: 5 additions & 1 deletion manifests/node_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@
content => $web_config_content.to_yaml,
}

$web_config = "--web.config=${$web_config_file}"
if versioncmp($version, '1.5.0') >= 0 {
$web_config = "--web.config.file=${$web_config_file}"
} else {
$web_config = "--web.config=${$web_config_file}"
}
}

$options = [
Expand Down
43 changes: 42 additions & 1 deletion spec/classes/node_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@
end
end

context 'with tls set in web-config.yml' do
context 'with tls set in web-config.yml version lower than 1.5.0' do
let(:params) do
{
version: '1.4.0',
use_tls_server_config: true,
tls_cert_file: '/etc/node_exporter/foo.cert',
tls_key_file: '/etc/node_exporter/foo.key'
Expand All @@ -146,6 +147,46 @@
it { is_expected.to contain_prometheus__daemon('node_exporter').with(options: ' --web.config=/etc/node_exporter_web-config.yml') }
end
end

context 'with tls set in web-config.yml version equal to 1.5.0' do
let(:params) do
{
version: '1.5.0',
use_tls_server_config: true,
tls_cert_file: '/etc/node_exporter/foo.cert',
tls_key_file: '/etc/node_exporter/foo.key'
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/node_exporter_web-config.yml').with(ensure: 'file') }

if facts[:os]['name'] == 'Archlinux'
it { is_expected.to contain_prometheus__daemon('prometheus-node-exporter').with(options: ' --web.config.file=/etc/node_exporter_web-config.yml') }
else
it { is_expected.to contain_prometheus__daemon('node_exporter').with(options: ' --web.config.file=/etc/node_exporter_web-config.yml') }
end
end

context 'with tls set in web-config.yml version higher to 1.5.0' do
let(:params) do
{
version: '1.5.1',
use_tls_server_config: true,
tls_cert_file: '/etc/node_exporter/foo.cert',
tls_key_file: '/etc/node_exporter/foo.key'
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/node_exporter_web-config.yml').with(ensure: 'file') }

if facts[:os]['name'] == 'Archlinux'
it { is_expected.to contain_prometheus__daemon('prometheus-node-exporter').with(options: ' --web.config.file=/etc/node_exporter_web-config.yml') }
else
it { is_expected.to contain_prometheus__daemon('node_exporter').with(options: ' --web.config.file=/etc/node_exporter_web-config.yml') }
end
end
end
end
end

0 comments on commit 1fb07b7

Please sign in to comment.