Skip to content

Commit

Permalink
Merge pull request #550 from wandera/mongodb_exporter_020
Browse files Browse the repository at this point in the history
mongodb_exporter supporting newer versions
  • Loading branch information
bastelfreak authored May 18, 2021
2 parents 01688fb + 94d53a8 commit c82f803
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
11 changes: 0 additions & 11 deletions data/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,6 @@ prometheus::mysqld_exporter::package_name: 'mysqld_exporter'
prometheus::mysqld_exporter::service_name: 'mysqld_exporter'
prometheus::mysqld_exporter::user: 'mysqld-exporter'
prometheus::mysqld_exporter::version: '0.12.1'
prometheus::mongodb_exporter::cnf_uri: 'mongodb://localhost:27017'
prometheus::mongodb_exporter::download_extension: 'tar.gz'
prometheus::mongodb_exporter::download_url_base: 'https://github.com/percona/mongodb_exporter/releases'
prometheus::mongodb_exporter::extra_groups: []
prometheus::mongodb_exporter::group: 'mongodb-exporter'
prometheus::mongodb_exporter::package_ensure: 'latest'
prometheus::mongodb_exporter::package_name: 'mongodb_exporter'
prometheus::mongodb_exporter::service_name: 'mongodb_exporter'
prometheus::mongodb_exporter::user: 'mongodb-exporter'
prometheus::mongodb_exporter::version: '0.11.0'
prometheus::mongodb_exporter::use_kingpin: false
prometheus::node_exporter::download_extension: 'tar.gz'
prometheus::node_exporter::download_url_base: 'https://github.com/prometheus/node_exporter/releases'
prometheus::node_exporter::extra_groups: []
Expand Down
29 changes: 18 additions & 11 deletions manifests/mongodb_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@
# this param to define how we call the mongodb.uri in the $options
# https://github.com/percona/mongodb_exporter/blob/v0.7.0/CHANGELOG.md
class prometheus::mongodb_exporter (
String[1] $cnf_uri,
String $download_extension,
String[1] $download_url_base,
Array $extra_groups,
String[1] $group,
String[1] $package_ensure,
String[1] $package_name,
String[1] $service_name,
String[1] $user,
String[1] $version,
Boolean $use_kingpin,
String[1] $cnf_uri = 'mongodb://localhost:27017',
String $download_extension = 'tar.gz',
String[1] $download_url_base = 'https://github.com/percona/mongodb_exporter/releases',
Array $extra_groups = [],
String[1] $group = 'mongodb-exporter',
String[1] $package_ensure = 'latest',
String[1] $package_name = 'mongodb_exporter',
String[1] $service_name = 'mongodb_exporter',
String[1] $user = 'mongodb-exporter',
String[1] $version = '0.20.4',
Boolean $use_kingpin = true,
Boolean $purge_config_dir = true,
Boolean $restart_on_change = true,
Boolean $service_enable = true,
Expand All @@ -86,6 +86,12 @@
#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, '0.7.0') < 0 or versioncmp($version, '0.20.4') >= 0 {
$archive_bin_path = undef # use default
} else {
$archive_bin_path = '/opt/mongodb_exporter'
}

$notify_service = $restart_on_change ? {
true => Service[$service_name],
default => undef,
Expand All @@ -106,6 +112,7 @@
arch => $arch,
real_download_url => $real_download_url,
bin_dir => $bin_dir,
archive_bin_path => $archive_bin_path,
notify_service => $notify_service,
package_name => $package_name,
package_ensure => $package_ensure,
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/mongodb_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
context 'with version specified' do
let(:params) do
{
version: '0.3.0',
version: '0.20.4',
arch: 'amd64',
os: 'linux',
bin_dir: '/usr/local/bin',
Expand All @@ -23,7 +23,7 @@
end

describe 'install correct binary' do
it { is_expected.to contain_file('/usr/local/bin/mongodb_exporter').with('target' => '/opt/mongodb_exporter-0.3.0.linux-amd64/mongodb_exporter') }
it { is_expected.to contain_file('/usr/local/bin/mongodb_exporter').with('target' => '/opt/mongodb_exporter-0.20.4.linux-amd64/mongodb_exporter') }
end
end
end
Expand Down

0 comments on commit c82f803

Please sign in to comment.