diff --git a/manifests/alertmanager.pp b/manifests/alertmanager.pp index 31fbea0..1baaa8b 100644 --- a/manifests/alertmanager.pp +++ b/manifests/alertmanager.pp @@ -5,13 +5,13 @@ # Parameters: # # [*package_name*] -# Prometheus package name - not available yet +# alert_manager package name # # [*package_ensure*] # If package, then use this for package ensurel default 'latest' # # [*config_dir*] -# Prometheus configuration directory (default /etc/prometheus) +# alert_manager configuration directory (default /etc/prometheus) # # [*purge_config_dir*] # Purge config files no longer generated by Puppet diff --git a/manifests/node_exporter.pp b/manifests/node_exporter.pp index 8df709e..9b09aea 100644 --- a/manifests/node_exporter.pp +++ b/manifests/node_exporter.pp @@ -5,7 +5,7 @@ # Parameters: # # [*package_name*] -# Prometheus node node_exporter package name - not available yet +# Prometheus node node_exporter package name # # [*package_ensure*] # If package, then use this for package ensure default 'latest' diff --git a/manifests/pushgateway.pp b/manifests/pushgateway.pp new file mode 100644 index 0000000..3382655 --- /dev/null +++ b/manifests/pushgateway.pp @@ -0,0 +1,62 @@ +# Class: prometheus::pushgateway +# +# This module manages prometheus pushgateway +# +# Parameters: +# +# [*package_name*] +# pushgateway package name +# +# [*package_ensure*] +# If package, then use this for package ensurel default 'latest' +# +# [*pushgateway_user*] +# User under which pushgateway will run +# Default prometheus +# +# [*pushgateway_group*] +# Group under which pushgateway will run +# Default prometheus +# +# == CONFIG == +# +# [*log_format*] +# If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to +# stderr. +# +# [*log_level*] +# Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal]. (default info) +# +# [*persistence_file*] +# File to persist metrics. If empty, metrics are only kept in memory. +# +# [*persistence_interval*] +# The minimum interval at which to write out the persistence file. (default 5m0s) +# +# [*web_listen_address*] +# Address to listen on for the web interface and API. (default ":9093") +# +# [*extra_options*] +# Extra options added to alertmanager startup command +# +class prometheus::pushgateway ( + $package_name = $::prometheus::pushgateway::params::package_name, + $package_ensure = $::prometheus::pushgateway::params::package_ensure, + $pushgateway_user = $::prometheus::pushgateway::params::pushgateway_user, + $pushgateway_group = $::prometheus::pushgateway::params::pushgateway_group, + $log_format = $::prometheus::pushgateway::params::log_format, + $log_level = $::prometheus::pushgateway::params::log_level, + $persistence_file = $::prometheus::pushgateway::params::persistence_file, + $persistence_interval = $::prometheus::pushgateway::params::persistence_interval, + $web_listen_address = $::prometheus::pushgateway::params::web_listen_address, + $web_telemetry_path = $::prometheus::pushgateway::params::web_telemetry_path, + $extra_options = $::prometheus::pushgateway::params::extra_options, +) inherits prometheus::pushgateway::params { + contain '::prometheus::pushgateway::install' + contain '::prometheus::pushgateway::config' + contain '::prometheus::pushgateway::service' + + Class['prometheus::pushgateway::install'] -> + Class['prometheus::pushgateway::config'] ~> + Class['prometheus::pushgateway::service'] +} diff --git a/manifests/pushgateway/config.pp b/manifests/pushgateway/config.pp new file mode 100644 index 0000000..29258b2 --- /dev/null +++ b/manifests/pushgateway/config.pp @@ -0,0 +1,17 @@ +# Class prometheus::pushgateway::config +# +class prometheus::pushgateway::config { + file { $::prometheus::pushgateway::persistence_file: + ensure => 'file', + mode => '0644', + owner => $::prometheus::pushgateway::pushgateway_user, + group => $::prometheus::pushgateway::pushgateway_group, + } + + file { '/etc/sysconfig/pushgateway': + mode => '0644', + owner => 'root', + group => 'root', + content => template("${module_name}/sysconfig/pushgateway"), + } +} diff --git a/manifests/pushgateway/install.pp b/manifests/pushgateway/install.pp new file mode 100644 index 0000000..7ed8e06 --- /dev/null +++ b/manifests/pushgateway/install.pp @@ -0,0 +1,5 @@ +# Class prometheus::pushgateway::install +# +class prometheus::pushgateway::install { + package { $::prometheus::pushgateway::package_name: ensure => $::prometheus::pushgateway::package_ensure, } +} diff --git a/manifests/pushgateway/params.pp b/manifests/pushgateway/params.pp new file mode 100644 index 0000000..8334a16 --- /dev/null +++ b/manifests/pushgateway/params.pp @@ -0,0 +1,17 @@ +# Class prometheus::pushgateway::params +# +class prometheus::pushgateway::params { + $package_name = 'pushgateway' + $package_ensure = 'installed' + $pushgateway_user = 'prometheus' + $pushgateway_group = 'prometheus' + + $log_format = 'logger:stdout?json=true' + $log_level = undef + $persistence_file = '/etc/prometheus/pushgateway.persistance' + $persistence_interval = undef + $web_listen_address = ':9091' + $web_telemetry_path = undef + + $extra_options = undef +} diff --git a/manifests/pushgateway/service.pp b/manifests/pushgateway/service.pp new file mode 100644 index 0000000..f608b4c --- /dev/null +++ b/manifests/pushgateway/service.pp @@ -0,0 +1,8 @@ +# == Class prometheus::pushgateway::service +# +class prometheus::pushgateway::service { + service { 'pushgateway': + ensure => 'running', + enable => true, + } +} diff --git a/metadata.json b/metadata.json index eef84d7..a9e233d 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "cristifalcas-prometheus", - "version": "1.0.0", + "version": "1.1.0", "author": "Cristian Falcas", "summary": "Prometheus Puppet module", "license": "Apache-2.0", diff --git a/spec/classes/pushgateway_spec.rb b/spec/classes/pushgateway_spec.rb new file mode 100644 index 0000000..8b37e64 --- /dev/null +++ b/spec/classes/pushgateway_spec.rb @@ -0,0 +1,17 @@ +require 'spec_helper' + +describe 'prometheus::pushgateway' do + on_supported_os.each do |os, facts| + context "with defaults on #{os}" do + let(:facts) do + facts.merge({:puppetmaster => 'localhost.localdomain'}) + end + + it { should compile.with_all_deps } + it { should contain_class('prometheus::pushgateway') } + it { should contain_class('prometheus::pushgateway::config') } + it { should contain_class('prometheus::pushgateway::install') } + it { should contain_class('prometheus::pushgateway::service') } + end + end +end diff --git a/templates/sysconfig/pushgateway b/templates/sysconfig/pushgateway new file mode 100644 index 0000000..1cb48a8 --- /dev/null +++ b/templates/sysconfig/pushgateway @@ -0,0 +1,25 @@ +# File managed by puppet +# +ARGS="<% -%> +<% if @log_format -%> + -log.format=<%= scope['prometheus::pushgateway::log_format'] -%> +<% end -%> +<% if @log_level -%> + -log.level=<%= scope['prometheus::pushgateway::log_level'] -%> +<% end -%> +<% if @persistence_file -%> + -persistence.file=<%= scope['prometheus::pushgateway::persistence_file'] -%> +<% end -%> +<% if @persistence_interval -%> + -persistence.interval=<%= scope['prometheus::pushgateway::persistence_interval'] -%> +<% end -%> +<% if @web_listen_address -%> + -web.listen-address=<%= scope['prometheus::pushgateway::web_listen_address'] -%> +<% end -%> +<% if @web_telemetry_path -%> + -web.telemetry-path=<%= scope['prometheus::pushgateway::web_telemetry_path'] -%> +<% end -%> +<% if @extra_options -%> + <%= scope['prometheus::pushgateway::extra_options'] -%> +<% end -%> +"