Skip to content

Commit

Permalink
Merge pull request #791 from lukebigum/blackbox_envvar
Browse files Browse the repository at this point in the history
expose the env_vars and env_file_path parameters to the blackbox_exporter
  • Loading branch information
TheMeier authored Jul 20, 2024
2 parents 7ab0242 + 3761fbb commit 003eacd
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
18 changes: 18 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,8 @@ The following parameters are available in the `prometheus::blackbox_exporter` cl
* [`user`](#-prometheus--blackbox_exporter--user)
* [`version`](#-prometheus--blackbox_exporter--version)
* [`config_mode`](#-prometheus--blackbox_exporter--config_mode)
* [`env_vars`](#-prometheus--blackbox_exporter--env_vars)
* [`env_file_path`](#-prometheus--blackbox_exporter--env_file_path)
* [`proxy_server`](#-prometheus--blackbox_exporter--proxy_server)
* [`proxy_type`](#-prometheus--blackbox_exporter--proxy_type)
* [`web_config_file`](#-prometheus--blackbox_exporter--web_config_file)
Expand Down Expand Up @@ -2848,6 +2850,22 @@ The permissions of the configuration files

Default value: `$prometheus::config_mode`

##### <a name="-prometheus--blackbox_exporter--env_vars"></a>`env_vars`

Data type: `Hash[String[1], Scalar]`

hash with custom environment variables thats passed to the exporter via init script / unit file

Default value: `{}`

##### <a name="-prometheus--blackbox_exporter--env_file_path"></a>`env_file_path`

Data type: `Stdlib::Absolutepath`

The path to the file with the environmetn variable that is read from the init script/systemd unit

Default value: `$prometheus::env_file_path`

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

Data type: `Optional[String[1]]`
Expand Down
8 changes: 8 additions & 0 deletions manifests/blackbox_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
# The binary release version
# @param config_mode
# The permissions of the configuration files
# @param env_vars
# hash with custom environment variables thats passed to the exporter via init script / unit file
# @param env_file_path
# The path to the file with the environmetn variable that is read from the init script/systemd unit
# @param proxy_server
# Optional proxy server, with port number if needed. ie: https://example.com:8080
# @param proxy_type
Expand Down Expand Up @@ -111,6 +115,8 @@
Stdlib::Port $scrape_port = 9115,
String[1] $scrape_job_name = 'blackbox',
Optional[Hash] $scrape_job_labels = undef,
Hash[String[1], Scalar] $env_vars = {},
Stdlib::Absolutepath $env_file_path = $prometheus::env_file_path,
Optional[String[1]] $proxy_server = undef,
Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef,
Stdlib::Absolutepath $web_config_file = '/etc/blackbox_exporter_web-config.yml',
Expand Down Expand Up @@ -189,6 +195,8 @@
scrape_port => $scrape_port,
scrape_job_name => $scrape_job_name,
scrape_job_labels => $scrape_job_labels,
env_vars => $env_vars,
env_file_path => $env_file_path,
proxy_server => $proxy_server,
proxy_type => $proxy_type,
}
Expand Down
14 changes: 14 additions & 0 deletions spec/classes/blackbox_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@
it { is_expected.to contain_prometheus__daemon('blackbox_exporter').with(options: '--config.file=/etc/blackbox-exporter.yaml --web.config.file=/etc/blackbox_exporter_web-config.yml') }
end
end

context 'with env vars' do
let :params do
{
env_vars: {
blub: 'foobar'
},
env_file_path: '/cows'
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_prometheus__daemon('blackbox_exporter').with({ env_vars: { 'blub' => 'foobar' }, env_file_path: '/cows' }) }
end
end
end
end

0 comments on commit 003eacd

Please sign in to comment.