Skip to content

Commit

Permalink
Merge pull request voxpupuli#220 from tuxmea/process_exporter_version…
Browse files Browse the repository at this point in the history
…_name

fix support for process_exporter 0.2.0 and newer
  • Loading branch information
bastelfreak authored Jun 23, 2018
2 parents 8105cb7 + 9f4da68 commit 9c75047
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
9 changes: 8 additions & 1 deletion manifests/process_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@
Stdlib::Absolutepath $bin_dir = $prometheus::bin_dir,
) inherits prometheus {

$real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")
# Prometheus removed a dot on the realease name at 0.2.0
if versioncmp ($version, '0.2.0') >= 0 {
$filename = "${package_name}-${version}${os}_${arch}.${download_extension}"
}
else {
$filename = "${package_name}-${version}.${os}-${arch}.${download_extension}"
}
$real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${filename}")
$notify_service = $restart_on_change ? {
true => Service['process-exporter'],
default => undef,
Expand Down
38 changes: 38 additions & 0 deletions spec/classes/process_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'spec_helper'

describe 'prometheus::process_exporter' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge(os_specific_facts(facts))
end

context 'without parameters' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('prometheus') }
it { is_expected.to contain_user('process-exporter') }
it { is_expected.to contain_group('process-exporter') }
it { is_expected.to contain_prometheus__daemon('process-exporter').with(options: '-config.path=/etc/process-exporter.yaml ') }
it { is_expected.to contain_service('process-exporter') }
end

context 'with version specified' do
let(:params) do
{
version: '0.2.4',
arch: 'amd64',
os: 'linux',
bin_dir: '/usr/local/bin',
install_method: 'url'
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_archive('/tmp/process-exporter-0.2.4.tar.gz') }
describe 'install correct binary' do
it { is_expected.to contain_file('/usr/local/bin/process-exporter').with('target' => '/opt/process-exporter-0.2.4.linux-amd64/process-exporter') }
end
end
end
end
end

0 comments on commit 9c75047

Please sign in to comment.