From 1a9056b457274ec832ef02be6c13268f004d97ec Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Thu, 25 Sep 2014 18:39:05 -0400 Subject: [PATCH] plugin: Rewrite the logic of define_plugins_dir Currently, there is a duplicate error duplication when compiling the catalog. This is due to the fact that the call to `define_plugins_dir` is called with the exact same parameter `$install_path` hence causing the error. By including the name of the plugin within the name of the resource we ensure the resource name is unique during catalog compilation. --- manifests/plugin.pp | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 14cf367b99..3adadc4148 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -50,7 +50,12 @@ 'file': { $filename = inline_template('<%= scope.lookupvar(\'name\').split(\'/\').last %>') - define_plugins_dir { $install_path: } + define_plugins_dir { "${name}-${install_path}": + path => $install_path, + purge => $purge, + recurse => $recurse, + force => $force, + } file { "${install_path}/${filename}": ensure => file, @@ -62,7 +67,12 @@ 'url' : { $filename = inline_template('<%= scope.lookupvar(\'name\').split(\'/\').last %>') - define_plugins_dir { $install_path: } + define_plugins_dir { "${name}-${install_path}": + path => $install_path, + purge => $purge, + recurse => $recurse, + force => $force, + } wget::fetch { $name : destination => "${install_path}/${filename}", @@ -98,13 +108,21 @@ } } # This is to verify the install_dir exists without duplicate declarations -define define_plugins_dir ($path = $name) { +define define_plugins_dir ( + $path = $name, + $force, + $purge, + $recurse, +) { if ! defined(File[$path]) { file { $path: - ensure => directory, - mode => '0555', - owner => 'sensu', - group => 'sensu', + ensure => directory, + mode => '0555', + owner => 'sensu', + group => 'sensu', + recurse => $recurse, + purge => $purge, + force => $force, require => Package['sensu'], } }