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

add support for newer releases of node_exporter #4

Merged
merged 1 commit into from
May 31, 2016
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
6 changes: 6 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib"
staging: "https://github.com/nanliu/puppet-staging"
symlinks:
"prometheus": "#{source_dir}"
7 changes: 6 additions & 1 deletion manifests/node_exporter/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
# The package method needs specific yum or apt repo settings which are not made yet by the module
class prometheus::node_exporter::install
{

case $::prometheus::node_exporter::install_method {
'url': {
include staging
$staging_file = "node_exporter-${prometheus::node_exporter::version}.${prometheus::node_exporter::download_extension}"
$binary = "${::staging::path}/node_exporter"
if( versioncmp($::prometheus::node_exporter::version, '0.12.0') == -1 ){
$binary = "${::staging::path}/node_exporter"
} else {
$binary = "${::staging::path}/node_exporter-${::prometheus::node_exporter::version}.${::prometheus::node_exporter::os}-${::prometheus::node_exporter::arch}/node_exporter"
}
staging::file { $staging_file:
source => $prometheus::node_exporter::real_download_url,
} ->
Expand Down
39 changes: 39 additions & 0 deletions spec/classes/node_exporter-version_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'spec_helper'

describe "prometheus::node_exporter" do

context 'uses the correct binary path for version < 0.12.0' do
let(:facts) { {
'operatingsystem' => 'CentOS',
'operatingsystemrelease' => '7.0',
'architecture' => 'amd64',
'kernel' => 'Linux',
} }

let(:params) { {:version => '0.10.0', :arch => 'amd64', :os => 'linux'} }

it do
should contain_file('/usr/local/bin/node_exporter').with({
'target' => '/opt/staging/node_exporter'
})
end
end

context 'uses the correct binary path for versions >= 0.12' do
let(:facts) { {
'operatingsystem' => 'CentOS',
'operatingsystemrelease' => '7.0',
'architecture' => 'amd64',
'kernel' => 'Linux',
} }

let(:params) { {:version => '0.12.0', :arch => 'amd64', :os => 'linux'} }

it do
should contain_file('/usr/local/bin/node_exporter').with({
'target' => '/opt/staging/node_exporter-0.12.0.linux-amd64/node_exporter'
})
end
end

end