diff --git a/REFERENCE.md b/REFERENCE.md index d7832047..98d8d44c 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -11125,7 +11125,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 410a614e..340b2882 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,7 +111,27 @@ 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}") + 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}") + 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 +180,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 619c5d08..ea65016e 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