Skip to content

Commit

Permalink
enable installation of rabbitmq_exporter >= 1.0.0
Browse files Browse the repository at this point in the history
fixes #662
  • Loading branch information
TheMeier committed Dec 31, 2024
1 parent d4b47fa commit 7dcebce
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
17 changes: 16 additions & 1 deletion manifests/rabbitmq_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,21 @@
Optional[String[1]] $proxy_server = undef,
Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef,
) inherits prometheus {
$real_download_url = pick($download_url, "${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")
if versioncmp($version, '1.0.0') >= 0 {
$extract_path = "/opt/${package_name}-${version}.${os}-${arch}"
$real_download_url = pick($download_url, "${download_url_base}/download/v${version}/${package_name}_${version}_${os}_${arch}.${download_extension}")
file { $extract_path:
ensure => 'directory',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
mode => '0555',
before => Prometheus::Daemon[$service_name],
}
} else {
$extract_path = '/opt'
$real_download_url = pick($download_url, "${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")
}

$notify_service = $restart_on_change ? {
true => Service[$service_name],
default => undef,
Expand Down Expand Up @@ -158,5 +172,6 @@
scrape_job_labels => $scrape_job_labels,
proxy_server => $proxy_server,
proxy_type => $proxy_type,
extract_path => $extract_path,
}
}
27 changes: 26 additions & 1 deletion spec/acceptance/rabbitmq_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,32 @@ class { 'prometheus::rabbitmq_exporter':
it { is_expected.to be_enabled }
end

describe port(9090) do
describe port(9419) do
it { is_expected.to be_listening.with('tcp6') }
end
end

describe 'prometheus rabbitmq_exporter version 1.0.0' do
it 'rabbitmq_exporter installs with version 1.0.0' do
pp = <<-EOS
class { 'prometheus::rabbitmq_exporter':
version => '1.0.0',
extra_env_vars => {
'PUBLISH_PORT' => '9419',
},
scrape_port => 9419,
}
EOS
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe service('rabbitmq_exporter') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end

describe port(9419) do
it { is_expected.to be_listening.with('tcp6') }
end
end
Expand Down

0 comments on commit 7dcebce

Please sign in to comment.