2 changes: 0 additions & 2 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ fixtures:
archive: "https://github.com/voxpupuli/puppet-archive"
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib"
systemd: "https://github.com/camptocamp/puppet-systemd"
symlinks:
"prometheus": "#{source_dir}"
5 changes: 3 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ By participating in this project you agree to abide by its terms.
runs the tests for us. You can also execute them locally. This is explained
in a later section.

1. Checkout the docs we use to review a module. They provide some guidance for
new code that might help you before you submit a pull request.
1. Checkout [our docs](https://voxpupuli.org/docs/#reviewing-a-module-pr) we
use to review a module and the [official styleguide](https://puppet.com/docs/puppet/6.0/style_guide.html).
They provide some guidance for new code that might help you before you submit a pull request.

1. Add a test for your change. Only refactoring and documentation
changes require no new tests. If you are adding functionality
Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
modulesync_config_version: '2.1.0'
modulesync_config_version: '2.2.0'
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v6.4.0](https://github.com/voxpupuli/puppet-prometheus/tree/v6.4.0) (2018-10-21)

[Full Changelog](https://github.com/voxpupuli/puppet-prometheus/compare/v6.3.0...v6.4.0)

**Implemented enhancements:**

- Add armv7 support [\#273](https://github.com/voxpupuli/puppet-prometheus/pull/273) ([othalla](https://github.com/othalla))
- Feature/collectd exporter [\#272](https://github.com/voxpupuli/puppet-prometheus/pull/272) ([mindriot88](https://github.com/mindriot88))
- consul\_exporter improvement for version 0.4.0 and above [\#264](https://github.com/voxpupuli/puppet-prometheus/pull/264) ([RogierO](https://github.com/RogierO))

## [v6.3.0](https://github.com/voxpupuli/puppet-prometheus/tree/v6.3.0) (2018-10-06)

[Full Changelog](https://github.com/voxpupuli/puppet-prometheus/compare/v6.2.0...v6.3.0)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ end

group :test do
gem 'puppetlabs_spec_helper', '>= 2.11.0', :require => false
gem 'rspec-puppet-facts', :require => false
gem 'rspec-puppet-facts', '>= 1.8.0', :require => false
gem 'rspec-puppet-utils', :require => false
gem 'puppet-lint-leading_zero-check', :require => false
gem 'puppet-lint-trailing_comma-check', :require => false
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
node_exporter >= 0.15.0
consul_exporter >= 0.3.0

This module supports below Prometheus architectures:
- x86_64/amd64
- i386
- armv71 (Tested on raspberry pi 3)

## Background

Expand All @@ -41,7 +45,7 @@ This module automates the install and configuration of Prometheus monitoring too
* Installs a configuration file for prometheus daemon (/etc/prometheus/prometheus.yaml) or for alertmanager (/etc/prometheus/alert.rules)
* Manages the services via upstart, sysv, or systemd
* Optionally creates alert rules
* The following exporters are currently implemented: node_exporter, statsd_exporter, process_exporter, haproxy_exporter, mysqld_exporter, blackbox_exporter, consul_exporter, redis_exporter, varnish_exporter, graphite_exporter, postgres_exporter
* The following exporters are currently implemented: node_exporter, statsd_exporter, process_exporter, haproxy_exporter, mysqld_exporter, blackbox_exporter, consul_exporter, redis_exporter, varnish_exporter, graphite_exporter, postgres_exporter, collectd_exporter

## Usage

Expand Down
15 changes: 15 additions & 0 deletions data/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,18 @@ prometheus::graphite_exporter::manage_group: true
prometheus::graphite_exporter::manage_service: true
prometheus::graphite_exporter::manage_user: true
prometheus::graphite_exporter::options: ''
prometheus::collectd_exporter::download_extension: 'tar.gz'
prometheus::collectd_exporter::download_url_base: 'https://github.com/prometheus/collectd_exporter/releases'
prometheus::collectd_exporter::group: 'collectd-exporter'
prometheus::collectd_exporter::package_ensure: 'latest'
prometheus::collectd_exporter::package_name: 'collectd_exporter'
prometheus::collectd_exporter::user: 'collectd-exporter'
prometheus::collectd_exporter::version: '0.4.0'
prometheus::collectd_exporter::purge_config_dir: true
prometheus::collectd_exporter::restart_on_change: true
prometheus::collectd_exporter::service_enable: true
prometheus::collectd_exporter::service_ensure: 'running'
prometheus::collectd_exporter::manage_group: true
prometheus::collectd_exporter::manage_service: true
prometheus::collectd_exporter::manage_user: true
prometheus::collectd_exporter::options: ''
122 changes: 122 additions & 0 deletions manifests/collectd_exporter.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Class: prometheus::collectd_exporter
#
# This module manages prometheus node collectd_exporter
#
# Parameters:
# [*arch*]
# Architecture (amd64 or i386)
#
# [*bin_dir*]
# Directory where binaries are located
#
# [*download_extension*]
# Extension for the release binary archive
#
# [*download_url*]
# Complete URL corresponding to the where the release binary archive can be downloaded
#
# [*download_url_base*]
# Base URL for the binary archive
#
# [*options*]
# Options added to the startup command
#
# [*group*]
# Group under which the binary is running
#
# [*init_style*]
# Service startup scripts style (e.g. rc, upstart or systemd)
#
# [*install_method*]
# Installation method: url or package (only url is supported currently)
#
# [*manage_group*]
# Whether to create a group for or rely on external code for that
#
# [*manage_service*]
# Should puppet manage the service? (default true)
#
# [*manage_user*]
# Whether to create user or rely on external code for that
#
# [*os*]
# Operating system (linux is the only one supported)
#
# [*package_ensure*]
# If package, then use this for package ensure default 'latest'
#
# [*package_name*]
# The binary package name - not available yet
#
# [*purge_config_dir*]
# Purge config files no longer generated by Puppet
#
# [*restart_on_change*]
# Should puppet restart the service on configuration change? (default true)
#
# [*service_enable*]
# Whether to enable the service from puppet (default true)
#
# [*service_ensure*]
# State ensured for the service (default 'running')
#
# [*user*]
# User which runs the service
#
# [*version*]
# The binary release version
#
class prometheus::collectd_exporter (
String[1] $download_extension,
String[1] $download_url_base,
String[1] $group,
String[1] $package_ensure,
String[1] $package_name,
String[1] $user,
String[1] $version,
Boolean $purge_config_dir,
Boolean $restart_on_change,
Boolean $service_enable,
String[1] $service_ensure,
Boolean $manage_group,
Boolean $manage_service,
Boolean $manage_user,
String $options,
String[1] $os = $prometheus::os,
String[1] $init_style = $prometheus::init_style,
String[1] $install_method = $prometheus::install_method,
Optional[String[1]] $download_url = undef,
String[1] $arch = $prometheus::real_arch,
String[1] $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}")

$notify_service = $restart_on_change ? {
true => Service['collectd_exporter'],
default => undef,
}

prometheus::daemon { 'collectd_exporter':
install_method => $install_method,
version => $version,
download_extension => $download_extension,
os => $os,
arch => $arch,
real_download_url => $real_download_url,
bin_dir => $bin_dir,
notify_service => $notify_service,
package_name => $package_name,
package_ensure => $package_ensure,
manage_user => $manage_user,
user => $user,
group => $group,
manage_group => $manage_group,
purge => $purge_config_dir,
options => $options,
init_style => $init_style,
service_ensure => $service_ensure,
service_enable => $service_enable,
manage_service => $manage_service,
}
}
12 changes: 10 additions & 2 deletions manifests/consul_exporter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@
$real_download_url = pick($download_url,"${download_url_base}/download/v${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")

if $consul_health_summary {
$real_consul_health_summary = '-consul.health-summary'
if versioncmp ($version, '0.4.0') == -1 {
$real_consul_health_summary = '-consul.health-summary'
} else {
$real_consul_health_summary = '--consul.health-summary'
}
} else {
$real_consul_health_summary = ''
}
Expand All @@ -132,7 +136,11 @@
default => undef,
}

$options = "-consul.server=${consul_server} ${real_consul_health_summary} -web.listen-address=${web_listen_address} -web.telemetry-path=${web_telemetry_path} -log.level=${log_level} ${extra_options}"
if versioncmp ($version, '0.4.0') == -1 {
$options = "-consul.server=${consul_server} ${real_consul_health_summary} -web.listen-address=${web_listen_address} -web.telemetry-path=${web_telemetry_path} -log.level=${log_level} ${extra_options}"
} else {
$options = "--consul.server=${consul_server} ${real_consul_health_summary} --web.listen-address=${web_listen_address} --web.telemetry-path=${web_telemetry_path} --log.level=${log_level} ${extra_options}"
}

prometheus::daemon { 'consul_exporter':
install_method => $install_method,
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
case $arch {
'x86_64', 'amd64': { $real_arch = 'amd64' }
'i386': { $real_arch = '386' }
'armv7l': { $real_arch = 'armv7' }
default: {
fail("Unsupported kernel architecture: ${arch}")
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-prometheus",
"version": "6.3.0",
"version": "6.4.0",
"author": "Vox Pupuli",
"summary": "This module installs, configures and manages the Prometheus service.",
"license": "Apache-2.0",
Expand Down
23 changes: 23 additions & 0 deletions spec/acceptance/collectd_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'spec_helper_acceptance'

describe 'prometheus collectd exporter' do
it 'collectd_exporter works idempotently with no errors' do
if default[:platform] =~ %r{ubuntu-18.04-amd64}
pp = "package{'iproute2': ensure => present}"
apply_manifest(pp, catch_failures: true)
end
pp = 'include prometheus::collectd_exporter'
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe service('collectd_exporter') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end
# the class installs an the collectd_exporter that listens on port 9103
describe port(9103) do
it { is_expected.to be_listening.with('tcp6') }
end
end
34 changes: 34 additions & 0 deletions spec/acceptance/consul_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'spec_helper_acceptance'

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

describe 'prometheus consul exporter version 0.3.0' do
it ' consul_exporter installs with version 0.3.0' do
pp = "class {'prometheus::consul_exporter': version => '0.3.0' }"
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe process('consul_exporter') do
its(:args) { is_expected.to match %r{\ -consul.server} }
end
end

describe 'prometheus consul exporter version 0.4.0' do
it ' consul_exporter installs with version 0.4.0' do
pp = "class {'prometheus::consul_exporter': version => '0.4.0' }"
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe process('consul_exporter') do
its(:args) { is_expected.to match %r{\ --consul.server} }
end
end
end
30 changes: 30 additions & 0 deletions spec/classes/collectd_exporter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'spec_helper'

describe 'prometheus::collectd_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 contain_prometheus__daemon('collectd_exporter') }
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_group('collectd-exporter') }
it { is_expected.to contain_service('collectd_exporter') }
it { is_expected.to contain_user('collectd-exporter') }
it { is_expected.to contain_class('prometheus') }
end

context 'with params' do
let :params do
{
install_method: 'url'
}
end

it { is_expected.to contain_archive('/tmp/collectd_exporter-0.4.0.tar.gz') }
end
end
end
end
4 changes: 0 additions & 4 deletions spec/classes/coverage_spec.rb

This file was deleted.

1 change: 0 additions & 1 deletion spec/default_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# Hint if using with rspec-puppet-facts ("on_supported_os.each"):
# if a same named fact exists in facterdb it will be overridden.
---
concat_basedir: "/tmp"
ipaddress: "172.16.254.254"
is_pe: false
macaddress: "AA:AA:AA:AA:AA:AA"
18 changes: 9 additions & 9 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts

# This file is managed via modulesync
# https://github.com/voxpupuli/modulesync
# https://github.com/voxpupuli/modulesync_config
require 'puppetlabs_spec_helper/module_spec_helper'
require 'rspec-puppet-facts'
include RspecPuppetFacts

if Dir.exist?(File.expand_path('../../lib', __FILE__))
require 'coveralls'
Expand All @@ -23,14 +22,15 @@
end

RSpec.configure do |c|
default_facts = {
puppetversion: Puppet.version,
facterversion: Facter.version
}
default_facts = {}
default_facts.merge!(YAML.load(File.read(File.expand_path('../default_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_facts.yml', __FILE__))
default_facts.merge!(YAML.load(File.read(File.expand_path('../default_module_facts.yml', __FILE__)))) if File.exist?(File.expand_path('../default_module_facts.yml', __FILE__))
c.default_facts = default_facts

# Coverage generation
c.after(:suite) do
RSpec::Puppet::Coverage.report!
end
end

require 'spec_helper_methods'
# vim: syntax=ruby