From 695cc3328113bfc249da78c2134ef0495a2e7cd1 Mon Sep 17 00:00:00 2001 From: Jeroen Hooyberghs Date: Tue, 5 Dec 2017 15:10:46 +0100 Subject: [PATCH] Don't install alert.rules file if there's no content for it --- manifests/alerts.pp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/manifests/alerts.pp b/manifests/alerts.pp index e4d64bad0..b93ccca69 100644 --- a/manifests/alerts.pp +++ b/manifests/alerts.pp @@ -14,9 +14,8 @@ String $alertfile_name = 'alert.rules' ) inherits prometheus::params { - if ( versioncmp($::prometheus::version, '2.0.0') < 0 ){ - - if $alerts != [] { + if $alerts != [] and $alerts != {} { + if ( versioncmp($::prometheus::version, '2.0.0') < 0 ){ file { "${location}/${alertfile_name}": ensure => 'file', @@ -27,17 +26,16 @@ } } + else { - } - else { + file { "${location}/${alertfile_name}": + ensure => 'file', + owner => $prometheus::user, + group => $prometheus::group, + notify => Class['::prometheus::service_reload'], + content => $alerts.to_yaml, + } - file { "${location}/${alertfile_name}": - ensure => 'file', - owner => $prometheus::user, - group => $prometheus::group, - notify => Class['::prometheus::service_reload'], - content => $alerts.to_yaml, } - } }