Skip to content

Commit

Permalink
Merge pull request voxpupuli#197 from bastelfreak/inconsistent_class_…
Browse files Browse the repository at this point in the history
…params

migrate server related classes to private scope
  • Loading branch information
sebastianrakel committed May 20, 2018
2 parents 6047084 + 90145b1 commit 7de14b2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 36 deletions.
28 changes: 11 additions & 17 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
# Class prometheus::config
# Configuration class for prometheus monitoring system
class prometheus::config (
Hash $global_config,
Array $rule_files,
Array $scrape_configs,
Array $remote_read_configs,
Array $remote_write_configs,
String $config_template = $prometheus::server::config_template,
String $storage_retention = $prometheus::server::storage_retention,
) {
class prometheus::config {

if $prometheus::init_style {
if( versioncmp($prometheus::version, '2.0.0') < 0 ){
assert_private()

if $prometheus::server::init_style {
if( versioncmp($prometheus::server::version, '2.0.0') < 0 ){
# helper variable indicating prometheus version, so we can use on this information in the template
$prometheus_v2 = false
if $remote_read_configs != [] {
if $prometheus::server::remote_read_configs != [] {
fail('remote_read_configs requires prometheus 2.X')
}
if $remote_write_configs != [] {
if $prometheus::server::remote_write_configs != [] {
fail('remote_write_configs requires prometheus 2.X')
}
$daemon_flags = [
"-config.file=${prometheus::server::config_dir}/prometheus.yaml",
"-storage.local.path=${prometheus::server::localstorage}",
"-storage.local.retention=${storage_retention}",
"-storage.local.retention=${prometheus::server::storage_retention}",
"-web.console.templates=${prometheus::shared_dir}/consoles",
"-web.console.libraries=${prometheus::shared_dir}/console_libraries",
]
Expand All @@ -33,15 +27,15 @@
$daemon_flags = [
"--config.file=${prometheus::server::config_dir}/prometheus.yaml",
"--storage.tsdb.path=${prometheus::server::localstorage}",
"--storage.tsdb.retention=${storage_retention}",
"--storage.tsdb.retention=${prometheus::server::storage_retention}",
"--web.console.templates=${prometheus::server::shared_dir}/consoles",
"--web.console.libraries=${prometheus::server::shared_dir}/console_libraries",
]
}

# the vast majority of files here are init-files
# so any change there should trigger a full service restart
if $prometheus::restart_on_change {
if $prometheus::server::restart_on_change {
File {
notify => [Class['prometheus::run_service']],
}
Expand Down Expand Up @@ -123,7 +117,7 @@
group => $prometheus::server::group,
mode => $prometheus::server::config_mode,
notify => Class['prometheus::service_reload'],
content => template($config_template),
content => template($prometheus::server::config_template),
validate_cmd => "${prometheus::server::bin_dir}/promtool ${cfg_verify_cmd} %",
}

Expand Down
8 changes: 3 additions & 5 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
# Currently only the install from url is implemented, when Prometheus will deliver packages for some Linux distros I will
# implement the package install method as well
# The package method needs specific yum or apt repo settings which are not made yet by the module
class prometheus::install (
Boolean $purge_config_dir = true,
) {
class prometheus::install {

assert_private()

Expand Down Expand Up @@ -89,7 +87,7 @@
ensure => 'directory',
owner => $prometheus::server::user,
group => $prometheus::server::group,
purge => $purge_config_dir,
recurse => $purge_config_dir,
purge => $prometheus::server::purge_config_dir,
recurse => $prometheus::server::purge_config_dir,
}
}
23 changes: 9 additions & 14 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,13 @@
else {
$_rule_files = $extra_rule_files
}
class { 'prometheus::install':
purge_config_dir => $prometheus::purge_config_dir,
}
-> class { 'prometheus::config':
global_config => $global_config,
rule_files => $_rule_files,
scrape_configs => $scrape_configs,
remote_read_configs => $remote_read_configs,
remote_write_configs => $remote_write_configs,
config_template => $config_template,
storage_retention => $storage_retention,
}
-> class { 'prometheus::run_service': }
-> class { 'prometheus::service_reload': }
contain prometheus::install
contain prometheus::config
contain prometheus::run_service
contain prometheus::service_reload

Class['prometheus::install']
-> Class['prometheus::config']
-> Class['prometheus::run_service']
-> Class['prometheus::service_reload']
}

0 comments on commit 7de14b2

Please sign in to comment.