Skip to content

Commit

Permalink
Merge pull request #254 from Mylezeem/duplicate_resources
Browse files Browse the repository at this point in the history
plugin: Rewrite the logic of define_plugins_dir
  • Loading branch information
jamtur01 committed Sep 25, 2014
2 parents f091747 + 1a9056b commit 4a16ebf
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 4a16ebf

Please sign in to comment.