Skip to content

Commit

Permalink
Merge pull request #189 from bastelfreak/scope
Browse files Browse the repository at this point in the history
switch from topscope to class scope for variables
  • Loading branch information
bastelfreak committed May 8, 2018
2 parents 43e92a5 + 6ae1030 commit 60d3b39
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
22 changes: 11 additions & 11 deletions manifests/alerts.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@
#
define prometheus::alerts (
Variant[Array,Hash] $alerts,
String $location = "${::prometheus::config_dir}/rules",
String $version = $::prometheus::version,
String $user = $::prometheus::user,
String $group = $::prometheus::group,
String $bin_dir = $::prometheus::bin_dir,
String $location = "${prometheus::config_dir}/rules",
String $version = $prometheus::version,
String $user = $prometheus::user,
String $group = $prometheus::group,
String $bin_dir = $prometheus::bin_dir,
) {
if ( versioncmp($version, '2.0.0') < 0 ){
file { "${location}/${name}.rules":
ensure => 'file',
owner => $user,
group => $group,
notify => Class['::prometheus::service_reload'],
notify => Class['prometheus::service_reload'],
content => epp("${module_name}/alerts.epp", {'alerts' => $alerts}),
validate_cmd => "${bin_dir}/promtool check-rules %",
require => Class['::prometheus::install'],
before => Class['::prometheus::config'],
require => Class['prometheus::install'],
before => Class['prometheus::config'],
}
}
else {
file { "${location}/${name}.rules":
ensure => 'file',
owner => $user,
group => $group,
notify => Class['::prometheus::service_reload'],
notify => Class['prometheus::service_reload'],
content => $alerts.to_yaml,
validate_cmd => "${bin_dir}/promtool check rules %",
require => Class['::prometheus::install'],
before => Class['::prometheus::config'],
require => Class['prometheus::install'],
before => Class['prometheus::config'],
}
}
}
6 changes: 3 additions & 3 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
# so any change there should trigger a full service restart
if $prometheus::restart_on_change {
File {
notify => [Class['::prometheus::run_service']],
notify => [Class['prometheus::run_service']],
}
$systemd_notify = [Exec['prometheus-systemd-reload'], Class['::prometheus::run_service']]
$systemd_notify = [Exec['prometheus-systemd-reload'], Class['prometheus::run_service']]
} else {
$systemd_notify = Exec['prometheus-systemd-reload']
}
Expand All @@ -68,7 +68,7 @@
}
'systemd' : {
include 'systemd'
::systemd::unit_file {'prometheus.service':
systemd::unit_file {'prometheus.service':
content => template('prometheus/prometheus.systemd.erb'),
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
}
'systemd' : {
include 'systemd'
::systemd::unit_file {"${name}.service":
systemd::unit_file {"${name}.service":
content => template('prometheus/daemon.systemd.erb'),
notify => $notify_service,
}
Expand Down
14 changes: 7 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
}
}

if( versioncmp($::prometheus::version, '1.0.0') == -1 ){
if( versioncmp($prometheus::version, '1.0.0') == -1 ){
$real_download_url = pick($download_url,
"${download_url_base}/download/${version}/${package_name}-${version}.${os}-${real_arch}.${download_extension}")
} else {
Expand All @@ -201,14 +201,14 @@
}

$extra_alerts.each | String $alerts_file_name, Hash $alerts_config | {
::prometheus::alerts { $alerts_file_name:
prometheus::alerts { $alerts_file_name:
alerts => $alerts_config,
}
}
$extra_rule_files = suffix(prefix(keys($extra_alerts), "${config_dir}/rules/"), '.rules')

if ! empty($alerts) {
::prometheus::alerts { 'alert':
prometheus::alerts { 'alert':
alerts => $alerts,
location => $config_dir,
}
Expand All @@ -219,10 +219,10 @@
}

anchor {'prometheus_first': }
-> class { '::prometheus::install':
-> class { 'prometheus::install':
purge_config_dir => $purge_config_dir,
}
-> class { '::prometheus::config':
-> class { 'prometheus::config':
global_config => $global_config,
rule_files => $_rule_files,
scrape_configs => $scrape_configs,
Expand All @@ -231,7 +231,7 @@
config_template => $config_template,
storage_retention => $storage_retention,
}
-> class { '::prometheus::run_service': }
-> class { '::prometheus::service_reload': }
-> class { 'prometheus::run_service': }
-> class { 'prometheus::service_reload': }
-> anchor {'prometheus_last': }
}

0 comments on commit 60d3b39

Please sign in to comment.