Skip to content

Commit

Permalink
Merge pull request #216 from TMGMedia/master
Browse files Browse the repository at this point in the history
use service name for redis_exporter to prevent multiple downloads of redis_exporter
  • Loading branch information
bastelfreak authored Jun 21, 2018
2 parents 0ad515e + 18d7603 commit 70ac33a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
9 changes: 5 additions & 4 deletions manifests/redis_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
# redis_exporter lacks.
# TODO: patch prometheus::daemon to support custom extract directories
$exporter_install_method = 'none'
file { "/opt/${service_name}-${version}.${os}-${arch}":
$install_dir = "/opt/${service_name}-${version}.${os}-${arch}"
file { $install_dir:
ensure => 'directory',
owner => 'root',
group => 0, # 0 instead of root because OS X uses "wheel".
Expand All @@ -135,16 +136,16 @@
-> archive { "/tmp/${service_name}-${version}.${download_extension}":
ensure => present,
extract => true,
extract_path => "/opt/${service_name}-${version}.${os}-${arch}",
extract_path => $install_dir,
source => $real_download_url,
checksum_verify => false,
creates => "/opt/${name}-${version}.${os}-${arch}/${name}",
creates => "${install_dir}/${service_name}",
cleanup => true,
}
-> file { "${bin_dir}/${service_name}":
ensure => link,
notify => $notify_service,
target => "/opt/${service_name}-${version}.${os}-${arch}/${service_name}",
target => "${install_dir}/${service_name}",
before => Prometheus::Daemon[$service_name],
}
} else {
Expand Down
19 changes: 19 additions & 0 deletions spec/acceptance/redis_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper_acceptance'

describe 'prometheus redis exporter' do
it 'redis_exporter works idempotently with no errors' do
pp = 'include prometheus::redis_exporter'
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe service('redis_exporter') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end
# the class installs an the redis_exporter that listens on port 9121
describe port(9121) do
it { is_expected.to be_listening.with('tcp6') }
end
end

0 comments on commit 70ac33a

Please sign in to comment.