From a7926afe3e613767a12eb608fa60c39917454d36 Mon Sep 17 00:00:00 2001 From: sp-ricard-valverde Date: Thu, 23 Nov 2023 11:49:00 +0100 Subject: [PATCH] fix(collectd-plugin): ensure absent python module Ensure that a python's module config is also removed whenever the python module is absent --- manifests/plugin/python/module.pp | 42 ++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/manifests/plugin/python/module.pp b/manifests/plugin/python/module.pp index 44408a13f..393cbe57d 100644 --- a/manifests/plugin/python/module.pp +++ b/manifests/plugin/python/module.pp @@ -33,29 +33,31 @@ } } - # Exactly one per module. - ensure_resource('concat::fragment',"collectd_plugin_python_conf_${module}_header", - { - 'order' => "50_${module}_00", - 'target' => $collectd::plugin::python::python_conf, - 'content' => epp('collectd/plugin/python/module.conf_header.epp', + if $ensure == 'present' { + # Exactly one per module. + ensure_resource('concat::fragment',"collectd_plugin_python_conf_${module}_header", + { + 'order' => "50_${module}_00", + 'target' => $collectd::plugin::python::python_conf, + 'content' => epp('collectd/plugin/python/module.conf_header.epp', + { + 'module_import' => $_module_import, + }, + ), + } + ) + + # Possibly many per instance of a module configuration. + concat::fragment { "collectd_plugin_python_conf_${title}_config": + order => "50_${module}_50", + target => $collectd::plugin::python::python_conf, + content => epp('collectd/plugin/python/module.conf_config.epp', { - 'module_import' => $_module_import, + 'title' => $title, + 'config' => $config, + 'module' => $_module_import, }, ), } - ) - - # Possibly many per instance of a module configuration. - concat::fragment { "collectd_plugin_python_conf_${title}_config": - order => "50_${module}_50", - target => $collectd::plugin::python::python_conf, - content => epp('collectd/plugin/python/module.conf_config.epp', - { - 'title' => $title, - 'config' => $config, - 'module' => $_module_import, - }, - ), } }