Skip to content

Commit

Permalink
add proxy_server & proxy_type to server install
Browse files Browse the repository at this point in the history
  • Loading branch information
sabo authored and bastelfreak committed Aug 4, 2023
1 parent d6e83bb commit 71ab83b
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 58 deletions.
18 changes: 18 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11613,6 +11613,8 @@ The following parameters are available in the `prometheus::server` class:
* [`collect_tag`](#-prometheus--server--collect_tag)
* [`max_open_files`](#-prometheus--server--max_open_files)
* [`usershell`](#-prometheus--server--usershell)
* [`proxy_server`](#-prometheus--server--proxy_server)
* [`proxy_type`](#-prometheus--server--proxy_type)

##### <a name="-prometheus--server--configname"></a>`configname`

Expand Down Expand Up @@ -12006,6 +12008,22 @@ Data type: `Stdlib::Absolutepath`

Default value: `$prometheus::usershell`

##### <a name="-prometheus--server--proxy_server"></a>`proxy_server`

Data type: `Optional[String[1]]`



Default value: `$prometheus::proxy_server`

##### <a name="-prometheus--server--proxy_type"></a>`proxy_type`

Data type: `Optional[Enum['none', 'http', 'https', 'ftp']]`



Default value: `$prometheus::proxy_type`

### <a name="prometheus--snmp_exporter"></a>`prometheus::snmp_exporter`

This module manages prometheus snmp_exporter
Expand Down
2 changes: 2 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
creates => "/opt/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/prometheus",
cleanup => true,
extract_command => $prometheus::extract_command,
proxy_server => $prometheus::server::proxy_server,
proxy_type => $prometheus::server::proxy_type,
}
-> file {
"/opt/prometheus-${prometheus::server::version}.${prometheus::server::os}-${prometheus::server::real_arch}/prometheus":
Expand Down
2 changes: 2 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
Optional[String[1]] $collect_tag = $prometheus::collect_tag,
Optional[Integer] $max_open_files = $prometheus::max_open_files,
Stdlib::Absolutepath $usershell = $prometheus::usershell,
Optional[String[1]] $proxy_server = $prometheus::proxy_server,
Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = $prometheus::proxy_type,
) inherits prometheus {
if( versioncmp($version, '1.0.0') == -1 ) {
$real_download_url = pick($download_url,
Expand Down
43 changes: 1 addition & 42 deletions spec/classes/node_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@
end
end

context 'with tls set in web-config.yml version lower than 1.5.0' do
context 'with tls set in web-config.yml' 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 @@ -147,46 +146,6 @@
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
6 changes: 4 additions & 2 deletions spec/classes/prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
'/etc/prometheus/prometheus.yaml'
end

[{ manage_prometheus_server: true, version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url', rule_files: ['/etc/prometheus/rules.d/*.rules'] }].each do |parameters|
[{ manage_prometheus_server: true, version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url', rule_files: ['/etc/prometheus/rules.d/*.rules'], proxy_server: 'proxy.test', proxy_type: 'https' }].each do |parameters|
context "with parameters #{parameters}" do
let(:params) do
parameters
Expand Down Expand Up @@ -51,7 +51,9 @@
'source' => "https://github.com/prometheus/prometheus/releases/download/v#{prom_version}/prometheus-#{prom_version}.#{prom_os}-#{prom_arch}.tar.gz",
'checksum_verify' => false,
'creates' => "/opt/prometheus-#{prom_version}.#{prom_os}-#{prom_arch}/prometheus",
'cleanup' => true
'cleanup' => true,
'proxy_server' => 'proxy.test',
'proxy_type' => 'https'
).that_comes_before("File[/opt/prometheus-#{prom_version}.#{prom_os}-#{prom_arch}/prometheus]")
}

Expand Down
2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

require 'voxpupuli/test/spec_helper'

add_mocked_facts!

if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml')))
facts&.each do |name, value|
Expand Down
7 changes: 1 addition & 6 deletions templates/alertmanager.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
<% inhibit_rules = scope.lookupvar('::prometheus::alertmanager::inhibit_rules') -%>
<% full_config = { 'global'=>global, 'templates'=>templates, 'route'=>route, 'receivers'=>receivers, 'inhibit_rules'=>inhibit_rules } -%>
<%
if scope.function_versioncmp([scope.lookupvar('::prometheus::alertmanager::version'), '0.22.0']) >= 0 &&
scope.lookupvar('::prometheus::alertmanager::time_intervals').empty?
if scope.function_versioncmp([scope.lookupvar('::prometheus::alertmanager::version'), '0.22.0']) >= 0
full_config['mute_time_intervals'] = scope.lookupvar('::prometheus::alertmanager::mute_time_intervals')
end
if scope.function_versioncmp([scope.lookupvar('::prometheus::alertmanager::version'), '0.24.0']) >= 0 &&
! scope.lookupvar('::prometheus::alertmanager::time_intervals').empty?
full_config['time_intervals'] = scope.lookupvar('::prometheus::alertmanager::time_intervals')
end
-%>
<%= full_config.to_yaml -%>
2 changes: 1 addition & 1 deletion templates/ipmi_exporter.yaml.epp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<%- | Hash $modules | -%>
<%- $config = { 'modules' => $modules } -%>
<%= stdlib::to_yaml($config) -%>
<%= to_yaml($config) -%>
2 changes: 0 additions & 2 deletions templates/jmx_exporter.yaml.erb

This file was deleted.

2 changes: 1 addition & 1 deletion templates/sachet.yaml.epp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<%- | Array $templates, Array $receivers, Hash $providers | -%>
<%- $config = { 'templates' => $templates, 'receivers' => $receivers, 'providers' => $providers } -%>
<%= stdlib::to_yaml($config) -%>
<%= to_yaml($config) -%>
2 changes: 1 addition & 1 deletion templates/ssh_exporter.yaml.epp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<%- | Hash $modules | -%>
<%- $config = { 'modules' => $modules } -%>
<%= stdlib::to_yaml($config) -%>
<%= to_yaml($config) -%>
2 changes: 1 addition & 1 deletion templates/ssl_exporter.yaml.epp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<%- | Hash $modules | -%>
<%- $config = { 'modules' => $modules } -%>
<%= stdlib::to_yaml($config) -%>
<%= to_yaml($config) -%>

0 comments on commit 71ab83b

Please sign in to comment.