Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove support for apache_exporter < 1.0.0 #826

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1569,7 +1569,7 @@ Data type: `String[1]`

The binary release version

Default value: `'0.8.0'`
Default value: `'1.0.9'`

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

Expand Down
26 changes: 11 additions & 15 deletions manifests/apache_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
String[1] $package_name = 'apache_exporter',
String[1] $user = 'apache-exporter',
# renovate: depName=Lusitaniae/apache_exporter
String[1] $version = '0.8.0',
String[1] $version = '1.0.9',
Boolean $purge_config_dir = true,
Boolean $restart_on_change = true,
Boolean $service_enable = true,
Expand All @@ -94,8 +94,14 @@
Stdlib::Absolutepath $web_config_file = '/etc/apache_exporter_web-config.yml',
Prometheus::Web_config $web_config_content = {},
) inherits prometheus {
#Please provide the download_url for versions < 0.9.0
$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') == -1 ) {
fail("Version ${version} is not supported. Please use version 1.0.0 or newer.")
}

$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 All @@ -118,21 +124,11 @@
$_web_config = if $web_config_content.empty {
''
} else {
if versioncmp($version, '1.0.0') >= 0 {
"--web.config.file=${$web_config_file}"
} else {
"--web.config=${$web_config_file}"
}
}

$_scrape_uri = if versioncmp($version, '0.8.0') < 0 {
"-scrape_uri '${scrape_uri}'"
} else {
"--scrape_uri '${scrape_uri}'"
"--web.config.file=${$web_config_file}"
}

$options = [
$_scrape_uri,
"--scrape_uri '${scrape_uri}'",
$extra_options,
$_web_config,
].filter |$x| { !$x.empty }.join(' ')
Expand Down
10 changes: 5 additions & 5 deletions spec/acceptance/apache_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
end

# rubocop:disable RSpec/RepeatedExampleGroupBody,RSpec/RepeatedExampleGroupDescription
describe 'apache_exporter update from 0.5.0 to 0.7.0' do
describe 'apache_exporter update from 1.0.0 to 1.0.9' do
it 'is idempotent' do
pp = "class{'prometheus::apache_exporter': version => '0.5.0'}"
pp = "class{'prometheus::apache_exporter': version => '1.0.0'}"
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
Expand All @@ -38,15 +38,15 @@
end

describe process('apache_exporter') do
its(:args) { is_expected.to match %r{\ -scrape_uri http://localhost/server-status/\?auto} }
its(:args) { is_expected.to match %r{\ --scrape_uri http://localhost/server-status/\?auto} }
end

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

it 'is idempotent' do
pp = "class{'prometheus::apache_exporter': version => '0.7.0'}"
pp = "class{'prometheus::apache_exporter': version => '1.0.9'}"
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
Expand All @@ -57,7 +57,7 @@
end

describe process('apache_exporter') do
its(:args) { is_expected.to match %r{\ -scrape_uri http://localhost/server-status/\?auto} }
its(:args) { is_expected.to match %r{\ --scrape_uri http://localhost/server-status/\?auto} }
end

describe port(9117) do
Expand Down
89 changes: 24 additions & 65 deletions spec/classes/apache_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_systemd__unit_file('apache_exporter.service') }
it { is_expected.not_to contain_package('apache-exporter') }
it { is_expected.to contain_archive('/tmp/apache_exporter-0.8.0.tar.gz') }
it { is_expected.to contain_file('/opt/apache_exporter-0.8.0.linux-amd64/apache_exporter') }
it { is_expected.to contain_archive('/tmp/apache_exporter-1.0.9.tar.gz') }
it { is_expected.to contain_file('/opt/apache_exporter-1.0.9.linux-amd64/apache_exporter') }
end

context 'with some params' do
let(:params) do
{
version: '0.5.0',
version: '1.0.0',
arch: 'amd64',
os: 'linux',
bin_dir: '/usr/local/bin',
Expand All @@ -30,109 +30,68 @@

describe 'with specific params' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_archive('/tmp/apache_exporter-0.5.0.tar.gz') }
it { is_expected.to contain_file('/opt/apache_exporter-0.5.0.linux-amd64/apache_exporter') }
it { is_expected.to contain_archive('/tmp/apache_exporter-1.0.0.tar.gz') }
it { is_expected.to contain_file('/opt/apache_exporter-1.0.0.linux-amd64/apache_exporter') }
it { is_expected.to contain_class('prometheus') }
it { is_expected.to contain_group('apache-exporter') }
it { is_expected.to contain_user('apache-exporter') }
it { is_expected.to contain_prometheus__daemon('apache_exporter').with('options' => "-scrape_uri 'http://localhost/server-status/?auto'") }
it { is_expected.to contain_prometheus__daemon('apache_exporter').with('options' => "--scrape_uri 'http://localhost/server-status/?auto'") }
it { is_expected.to contain_service('apache_exporter') }
end

describe 'install correct binary' do
it { is_expected.to contain_file('/usr/local/bin/apache_exporter').with('target' => '/opt/apache_exporter-0.5.0.linux-amd64/apache_exporter') }
it { is_expected.to contain_file('/usr/local/bin/apache_exporter').with('target' => '/opt/apache_exporter-1.0.0.linux-amd64/apache_exporter') }
end
end

context 'with version, scrape_uri and extra options specified' do
context 'with version < 1.0.0' do
let(:params) do
{
scrape_uri: 'http://127.0.0.1/server-status/?auto',
extra_options: '-test',
version: '0.4.0',
version: '0.13.4',
arch: 'amd64',
os: 'linux',
bin_dir: '/usr/local/bin',
install_method: 'url'
}
end

describe 'with specific params' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_archive('/tmp/apache_exporter-0.4.0.tar.gz') }
it { is_expected.to contain_file('/opt/apache_exporter-0.4.0.linux-amd64/apache_exporter') }
it { is_expected.to contain_class('prometheus') }
it { is_expected.to contain_group('apache-exporter') }
it { is_expected.to contain_user('apache-exporter') }
it { is_expected.to contain_prometheus__daemon('apache_exporter').with('options' => "-scrape_uri 'http://127.0.0.1/server-status/?auto' -test") }
it { is_expected.to contain_service('apache_exporter') }
end

describe 'install correct binary' do
it { is_expected.to contain_file('/usr/local/bin/apache_exporter').with('target' => '/opt/apache_exporter-0.4.0.linux-amd64/apache_exporter') }
describe 'it should fail' do
it { is_expected.to compile.and_raise_error(%r{Version 0.13.4 is not supported}) }
end
end

context 'with version 0.8.0+' do
context 'with version, scrape_uri and extra options specified' do
let(:params) do
{
scrape_uri: 'http://127.0.0.1/server-status/?auto',
extra_options: '--test',
version: '0.8.0',
version: '1.0.7',
arch: 'amd64',
os: 'linux',
bin_dir: '/usr/local/bin',
install_method: 'url'
}
end

describe 'uses argument prefix correctly' do
describe 'with specific params' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_archive('/tmp/apache_exporter-1.0.7.tar.gz') }
it { is_expected.to contain_file('/opt/apache_exporter-1.0.7.linux-amd64/apache_exporter') }
it { is_expected.to contain_class('prometheus') }
it { is_expected.to contain_group('apache-exporter') }
it { is_expected.to contain_user('apache-exporter') }
it { is_expected.to contain_prometheus__daemon('apache_exporter').with('options' => "--scrape_uri 'http://127.0.0.1/server-status/?auto' --test") }
end
end

context 'with tls set in web-config.yml version low than 1.0.0' do
let(:params) do
{
version: '0.0.9',
web_config_content: {
tls_server_config: {
cert_file: '/etc/apache_exporter/foo.cert',
key_file: '/etc/apache_exporter/foo.key'
}
}
}
it { is_expected.to contain_service('apache_exporter') }
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/apache_exporter_web-config.yml').with(ensure: 'file') }

it { is_expected.to contain_prometheus__daemon('apache_exporter').with(options: "-scrape_uri 'http://localhost/server-status/?auto' --web.config=/etc/apache_exporter_web-config.yml") }
end

context 'with tls set in web-config.yml version equal to 1.0.0' do
let(:params) do
{
version: '1.0.0',
web_config_content: {
tls_server_config: {
cert_file: '/etc/apache_exporter/foo.cert',
key_file: '/etc/apache_exporter/foo.key'
}
}
}
describe 'install correct binary' do
it { is_expected.to contain_file('/usr/local/bin/apache_exporter').with('target' => '/opt/apache_exporter-1.0.7.linux-amd64/apache_exporter') }
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_file('/etc/apache_exporter_web-config.yml').with(ensure: 'file') }

it { is_expected.to contain_prometheus__daemon('apache_exporter').with(options: "--scrape_uri 'http://localhost/server-status/?auto' --web.config.file=/etc/apache_exporter_web-config.yml") }
end

context 'with tls set in web-config.yml version higher than 1.0.0' do
context 'with tls set in web-config.yml' do
let(:params) do
{
version: '1.0.1',
web_config_content: {
tls_server_config: {
cert_file: '/etc/apache_exporter/foo.cert',
Expand Down
Loading