From c1af7415e77bf02a5d3abe1f8a62db333f8a7d1e Mon Sep 17 00:00:00 2001 From: Alexander Klimov Date: Thu, 12 Feb 2015 10:59:43 +0100 Subject: [PATCH] Puppet: make icinga2::feature disableable --- .puppet/modules/icinga2/manifests/feature.pp | 31 ++++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/.puppet/modules/icinga2/manifests/feature.pp b/.puppet/modules/icinga2/manifests/feature.pp index cfba05a9f..12c2e6d98 100644 --- a/.puppet/modules/icinga2/manifests/feature.pp +++ b/.puppet/modules/icinga2/manifests/feature.pp @@ -10,29 +10,22 @@ # # icinga2::feature { 'example-feature'; } # -define icinga2::feature ($source = undef) { +define icinga2::feature ($ensure = 'present') { include icinga2 - $target = "features-available/${name}" - $cfgpath = '/etc/icinga2' - $path = "${cfgpath}/features-enabled/${name}.conf" - - if $source != undef { - icinga2::config { $target: - source => $source, - } + $action = $ensure ? { + /(present)/ => 'enable', + /(absent)/ => 'disable', + } + $test = $ensure ? { + /(present)/ => '-e', + /(absent)/ => '! -e', } - parent_dirs { $path: - user => 'icinga', - require => [ - User['icinga'], - File['icinga2cfgDir'] - ], - } - -> file { $path: - ensure => link, - target => "${cfgpath}/${target}.conf", + exec { "icinga2-feature-${action}-${name}": + unless => "/usr/bin/test ${test} /etc/icinga2/features-enabled/${name}.conf", + command => "/usr/sbin/icinga2 feature ${action} ${name}", + require => Package['icinga2'], notify => Service['icinga2'], } }