Skip to content

Commit

Permalink
plugin: Rewrite the logic of define_plugins_dir
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Spredzy committed Sep 25, 2014
1 parent f091747 commit 1a9056b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}",
Expand Down Expand Up @@ -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'],
}
}
Expand Down

0 comments on commit 1a9056b

Please sign in to comment.