diff --git a/manifests/node_exporter.pp b/manifests/node_exporter.pp index 7eb54ad1a..059d012b8 100644 --- a/manifests/node_exporter.pp +++ b/manifests/node_exporter.pp @@ -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 = [ diff --git a/spec/classes/node_exporter_spec.rb b/spec/classes/node_exporter_spec.rb index 8db721a07..05dd322b6 100644 --- a/spec/classes/node_exporter_spec.rb +++ b/spec/classes/node_exporter_spec.rb @@ -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' @@ -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