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 Pushprox client and proxy #333

Merged
merged 1 commit into from
Jul 11, 2019
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
16 changes: 16 additions & 0 deletions data/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,22 @@ prometheus::version: '2.4.3'
prometheus::install_method: 'url'
prometheus::manage_prometheus_server: false
prometheus::extract_command: ~
prometheus::pushprox_client::download_extension: 'tar.gz'
prometheus::pushprox_client::download_url_base: 'https://github.com/camptocamp/PushProx/releases'
prometheus::pushprox_client::extra_groups: []
prometheus::pushprox_client::group: 'pushprox_client'
prometheus::pushprox_client::package_ensure: 'latest'
prometheus::pushprox_client::package_name: 'pushprox_client'
prometheus::pushprox_client::user: 'pushprox_client'
prometheus::pushprox_client::version: '20190708'
prometheus::pushprox_proxy::download_extension: 'tar.gz'
prometheus::pushprox_proxy::download_url_base: 'https://github.com/camptocamp/PushProx/releases'
prometheus::pushprox_proxy::extra_groups: []
prometheus::pushprox_proxy::group: 'pushprox_proxy'
prometheus::pushprox_proxy::package_ensure: 'latest'
prometheus::pushprox_proxy::package_name: 'pushprox_proxy'
prometheus::pushprox_proxy::user: 'pushprox_proxy'
prometheus::pushprox_proxy::version: '20190708'
prometheus::alert_relabel_config: []
prometheus::alertmanagers_config: []
prometheus::alertmanager::config_dir: '/etc/alertmanager'
Expand Down
137 changes: 137 additions & 0 deletions manifests/pushprox_client.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Class: prometheus::pushprox_client
#
# This module manages prometheus pushprox_client
#
# Parameters:
# [*arch*]
# Architecture (amd64 or i386)
#
# [*bin_dir*]
# Directory where binaries are located
#
# [*config_mode*]
# The permissions of the configuration files
#
# [*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
#
# [*extra_groups*]
# Extra groups to add the binary user to
#
# [*extra_options*]
# Extra 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')
#
# [*service_name*]
# Name of the pushprox_client service (default 'pushprox_client')
#
# [*user*]
# User which runs the service
#
# [*version*]
# The binary release version
class prometheus::pushprox_client (
String[1] $proxy_url,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay I thought you will add it for all the String types in both new classes :D

String $download_extension,
Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl] $download_url_base,
Array[String[1]] $extra_groups,
String $group,
String $package_ensure,
String $package_name,
String $user,
String $version,
Boolean $service_enable = true,
String $service_ensure = 'running',
String $service_name = 'pushprox_client',
Boolean $restart_on_change = true,
Boolean $purge_config_dir = true,
String $init_style = $prometheus::init_style,
String $install_method = $prometheus::install_method,
Boolean $manage_group = true,
Boolean $manage_service = true,
Boolean $manage_user = true,
String $os = $prometheus::os,
String $extra_options = '',
Optional[String] $download_url = undef,
String $config_mode = $prometheus::config_mode,
String $arch = $prometheus::real_arch,
Stdlib::Absolutepath $bin_dir = $prometheus::bin_dir,
) inherits prometheus {

$real_download_url = pick($download_url,"${download_url_base}/download/${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")

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

$options = "--proxy-url=${proxy_url} ${extra_options}"

prometheus::daemon { $service_name:
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,
extra_groups => $extra_groups,
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,
}
}
134 changes: 134 additions & 0 deletions manifests/pushprox_proxy.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Class: prometheus::pushprox_proxy
#
# This module manages prometheus pushprox_proxy
#
# Parameters:
# [*arch*]
# Architecture (amd64 or i386)
#
# [*bin_dir*]
# Directory where binaries are located
#
# [*config_mode*]
# The permissions of the configuration files
#
# [*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
#
# [*extra_groups*]
# Extra groups to add the binary user to
#
# [*extra_options*]
# Extra 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')
#
# [*service_name*]
# Name of the pushprox_proxy service (default 'pushprox_proxy')
#
# [*user*]
# User which runs the service
#
# [*version*]
# The binary release version
class prometheus::pushprox_proxy (
String $download_extension,
Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl] $download_url_base,
Array[String[1]] $extra_groups,
String $group,
String $package_ensure,
String $package_name,
String $user,
String $version,
Boolean $service_enable = true,
String $service_ensure = 'running',
String $service_name = 'pushprox_proxy',
Boolean $restart_on_change = true,
Boolean $purge_config_dir = true,
String $init_style = $prometheus::init_style,
String $install_method = $prometheus::install_method,
Boolean $manage_group = true,
Boolean $manage_service = true,
Boolean $manage_user = true,
String $os = $prometheus::os,
String $extra_options = '',
Optional[String] $download_url = undef,
String $config_mode = $prometheus::config_mode,
String $arch = $prometheus::real_arch,
Stdlib::Absolutepath $bin_dir = $prometheus::bin_dir,
) inherits prometheus {

$real_download_url = pick($download_url,"${download_url_base}/download/${version}/${package_name}-${version}.${os}-${arch}.${download_extension}")

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

prometheus::daemon { $service_name:
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,
extra_groups => $extra_groups,
group => $group,
manage_group => $manage_group,
purge => $purge_config_dir,
options => $extra_options,
init_style => $init_style,
service_ensure => $service_ensure,
service_enable => $service_enable,
manage_service => $manage_service,
}
}
31 changes: 31 additions & 0 deletions spec/acceptance/pushprox_client_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper_acceptance'

describe 'prometheus pushprox_client' do
it 'pushprox_client works idempotently with no errors' do
pp = <<-EOS
class { 'prometheus::pushprox_proxy': }
class { 'prometheus::pushprox_client':
proxy_url => 'http://localhost:8080',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe service('pushprox_proxy') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end
describe service('pushprox_client') do
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end
# the class installs an the pushprox_proxy that listens on port 8080
describe port(8080) do
it { is_expected.to be_listening.with('tcp6') }
end
# the class installs an the pushprox_client that listens on port 9369
describe port(9369) do
it { is_expected.to be_listening.with('tcp6') }
end
end