Skip to content

Commit

Permalink
remove custom use of archive for several exporters
Browse files Browse the repository at this point in the history
some exporters have a layout of the release archives that does not fit the
assumptions in prometheus::daemon. For these exporters
workarounds where in place to handle the different layouts. All theses cases
are now implemented using the options that prometheus::daemon provides.

fixes #606
  • Loading branch information
TheMeier committed Dec 31, 2024
1 parent 0fa032e commit 1c09fc7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 104 deletions.
2 changes: 1 addition & 1 deletion manifests/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
mode => '0555',
}
if $manage_bin_link {
file { "${bin_dir}/${name}":
file { "${bin_dir}/${bin_name}":
ensure => link,
notify => $notify_service,
target => $archive_bin_path,
Expand Down
47 changes: 12 additions & 35 deletions manifests/nginx_prometheus_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -99,42 +99,17 @@

$options = "-nginx.scrape-uri '${scrape_uri}' ${extra_options}"

if $install_method == 'url' {
# Not a big fan of copypasting but prometheus::daemon takes for granted
# a specific path embedded in the prometheus *_exporter tarball, which
# nginx_prometheus_exporter lacks currently as of version 0.9.0
# TODO: patch prometheus::daemon to support custom extract directories
$real_install_method = 'none'
$install_dir = "/opt/${package_name}-${version}.${os}-${arch}"
file { $install_dir:
ensure => 'directory',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555',
}
-> archive { "/tmp/${package_name}-${version}.${download_extension}":
ensure => present,
extract => true,
extract_path => $install_dir,
source => $real_download_url,
checksum_verify => false,
creates => "${install_dir}/${package_name}",
cleanup => true,
proxy_server => $proxy_server,
proxy_type => $proxy_type,
}
-> file { "${bin_dir}/${package_name}":
ensure => link,
notify => $notify_service,
target => "${install_dir}/${package_name}",
before => Prometheus::Daemon[$service_name],
}
} else {
$real_install_method = $install_method
}
$extract_path = "/opt/${package_name}-${version}.${os}-${arch}"
$archive_bin_path = "${extract_path}/${bin_name}"

prometheus::daemon { $service_name:
install_method => $real_install_method,
file { $extract_path:
ensure => 'directory',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555',
}
-> prometheus::daemon { $service_name:
install_method => $install_method,
version => $version,
download_extension => $download_extension,
os => $os,
Expand Down Expand Up @@ -165,5 +140,7 @@
env_file_path => $env_file_path,
proxy_server => $proxy_server,
proxy_type => $proxy_type,
extract_path => $extract_path,
archive_bin_path => $archive_bin_path,
}
}
45 changes: 12 additions & 33 deletions manifests/php_fpm_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -100,40 +100,17 @@

$options = "server --phpfpm.scrape-uri '${scrape_uri}' ${extra_options}"

if $install_method == 'url' {
# Not a big fan of copypasting but prometheus::daemon takes for granted
# a specific path embedded in the prometheus *_exporter tarball, which
# php-fpm_exporter lacks currently as of version 2.0.4
# TODO: patch prometheus::daemon to support custom extract directories
$real_install_method = 'none'
$install_dir = "/opt/${package_name}-${version}.${os}-${arch}"
file { $install_dir:
ensure => 'directory',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555',
}
-> archive { "/tmp/${package_name}-${version}.${download_extension}":
ensure => present,
extract => true,
extract_path => $install_dir,
source => $real_download_url,
checksum_verify => false,
creates => "${install_dir}/${package_name}",
cleanup => true,
}
-> file { "${bin_dir}/${package_name}":
ensure => link,
notify => $notify_service,
target => "${install_dir}/${package_name}",
before => Prometheus::Daemon[$service_name],
}
} else {
$real_install_method = $install_method
}
$extract_path = "/opt/${package_name}-${version}.${os}-${arch}"
$archive_bin_path = "${extract_path}/${bin_name}"

prometheus::daemon { $service_name:
install_method => $real_install_method,
file { $extract_path:
ensure => 'directory',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555',
}
-> prometheus::daemon { $service_name:
install_method => $install_method,
version => $version,
download_extension => $download_extension,
os => $os,
Expand Down Expand Up @@ -164,5 +141,7 @@
env_file_path => $env_file_path,
proxy_server => $proxy_server,
proxy_type => $proxy_type,
extract_path => $extract_path,
archive_bin_path => $archive_bin_path,
}
}
36 changes: 2 additions & 34 deletions manifests/postgres_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -164,41 +164,8 @@
}
}

if $install_method == 'url' {
# Not a big fan of copypasting but prometheus::daemon takes for granted
# a specific path embedded in the prometheus *_exporter tarball, which
# postgres_exporter lacks.
# TODO: patch prometheus::daemon to support custom extract directories
$exporter_install_method = 'none'
$install_dir = "/opt/${service_name}-${version}.${os}-${arch}"
file { $install_dir:
ensure => 'directory',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555',
}
-> archive { "/tmp/${service_name}-${version}.${download_extension}":
ensure => present,
extract => true,
extract_path => $install_dir,
extract_flags => '--strip-components=1 -xzf',
source => $real_download_url,
checksum_verify => false,
creates => "${install_dir}/${service_name}",
cleanup => true,
}
-> file { "${bin_dir}/${service_name}":
ensure => link,
notify => $notify_service,
target => "${install_dir}/${service_name}",
before => Prometheus::Daemon[$service_name],
}
} else {
$exporter_install_method = $install_method
}

prometheus::daemon { $service_name:
install_method => $exporter_install_method,
install_method => $install_method,
version => $version,
download_extension => $download_extension,
env_vars => $env_vars,
Expand Down Expand Up @@ -227,5 +194,6 @@
scrape_job_labels => $scrape_job_labels,
proxy_server => $proxy_server,
proxy_type => $proxy_type,
archive_bin_path => "/opt/${package_name}_v${version}_${os}-${arch}/postgres_exporter",
}
}
2 changes: 1 addition & 1 deletion spec/acceptance/nginx_prometheus_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class { 'prometheus::nginx_prometheus_exporter':
its(:args) { is_expected.to match %r{\ -nginx.scrape-uri http://localhost:8888/stub_status} }
end
else
describe process('nginx-prometheu') do
describe process('nginx-prometheus') do
its(:args) { is_expected.to match %r{\ -nginx.scrape-uri http://localhost:8888/stub_status} }

Check failure on line 47 in spec/acceptance/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 8 - Ubuntu 20.04

prometheus nginx exporter default install Process "nginx-prometheus" args is expected to match /\ -nginx.scrape-uri http:\/\/localhost:8888\/stub_status/ Failure/Error: its(:args) { is_expected.to match %r{\ -nginx.scrape-uri http://localhost:8888/stub_status} } expected "" to match /\ -nginx.scrape-uri http:\/\/localhost:8888\/stub_status/ Diff: @@ -1 +1 @@ -/\ -nginx.scrape-uri http:\/\/localhost:8888\/stub_status/ +""

Check failure on line 47 in spec/acceptance/nginx_prometheus_exporter_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Puppet 7 - Ubuntu 20.04

prometheus nginx exporter default install Process "nginx-prometheus" args is expected to match /\ -nginx.scrape-uri http:\/\/localhost:8888\/stub_status/ Failure/Error: its(:args) { is_expected.to match %r{\ -nginx.scrape-uri http://localhost:8888/stub_status} } expected "" to match /\ -nginx.scrape-uri http:\/\/localhost:8888\/stub_status/ Diff: @@ -1 +1 @@ -/\ -nginx.scrape-uri http:\/\/localhost:8888\/stub_status/ +""
end
end
Expand Down

0 comments on commit 1c09fc7

Please sign in to comment.