From e0ec75824f40913607d5bf16f25fa3e55da0551a Mon Sep 17 00:00:00 2001 From: Christoph Maser Date: Tue, 31 Dec 2024 15:59:27 +0100 Subject: [PATCH 1/2] allow installation of rabbitmq_exporter >= 1.0.0 fixes #662 --- manifests/rabbitmq_exporter.pp | 17 +++++++++++++- spec/acceptance/rabbitmq_exporter_spec.rb | 27 ++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/manifests/rabbitmq_exporter.pp b/manifests/rabbitmq_exporter.pp index 410a614e2..7792d3ac7 100644 --- a/manifests/rabbitmq_exporter.pp +++ b/manifests/rabbitmq_exporter.pp @@ -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, @@ -158,5 +172,6 @@ scrape_job_labels => $scrape_job_labels, proxy_server => $proxy_server, proxy_type => $proxy_type, + extract_path => $extract_path, } } diff --git a/spec/acceptance/rabbitmq_exporter_spec.rb b/spec/acceptance/rabbitmq_exporter_spec.rb index 619c5d083..ea65016e9 100644 --- a/spec/acceptance/rabbitmq_exporter_spec.rb +++ b/spec/acceptance/rabbitmq_exporter_spec.rb @@ -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 From 3fa6cfc429d822269c4bc4d75d8654c421e03ff6 Mon Sep 17 00:00:00 2001 From: Christoph Maser Date: Tue, 31 Dec 2024 16:10:06 +0100 Subject: [PATCH 2/2] deprecate prometheus::rabbitmq_exporter see https://github.com/kbudde/rabbitmq_exporter/issues/383 --- REFERENCE.md | 2 +- manifests/rabbitmq_exporter.pp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/REFERENCE.md b/REFERENCE.md index 5fa03c343..2379d3dda 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -11023,7 +11023,7 @@ Default value: `undef` ### `prometheus::rabbitmq_exporter` -This module manages prometheus rabbitmq_exporter +This class is deprecated and will be removed in a future release. #### Parameters diff --git a/manifests/rabbitmq_exporter.pp b/manifests/rabbitmq_exporter.pp index 7792d3ac7..340b28825 100644 --- a/manifests/rabbitmq_exporter.pp +++ b/manifests/rabbitmq_exporter.pp @@ -68,6 +68,8 @@ # Optional proxy server, with port number if needed. ie: https://example.com:8080 # @param proxy_type # Optional proxy server type (none|http|https|ftp) +# @note +# This class is deprecated and will be removed in a future release. class prometheus::rabbitmq_exporter ( Prometheus::Uri $download_url_base, Array[String] $extra_groups, @@ -109,6 +111,12 @@ Optional[String[1]] $proxy_server = undef, Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef, ) inherits prometheus { + deprecation( + 'promtheus::rabbitmq_exporter', + 'This class is deprecated and will be removed in a future release. See https://github.com/kbudde/rabbitmq_exporter/issues/383 for details', + false + ) + 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}")