From b97345857b28ea7c2f30e9c769eee3df7fe5c1e8 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 30 Nov 2007 18:58:01 +0100 Subject: concatenated_file: create a sensible default for dir parameter patch by Chris MacLeod, thanks! --- manifests/defines/concatenated_file.pp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'manifests') diff --git a/manifests/defines/concatenated_file.pp b/manifests/defines/concatenated_file.pp index f4ba791..ff7bf53 100644 --- a/manifests/defines/concatenated_file.pp +++ b/manifests/defines/concatenated_file.pp @@ -5,7 +5,6 @@ # See LICENSE for the full license granted to you. # TODO: -# * get rid of the $dir parameter # * create the directory in _part too # Usage: @@ -15,7 +14,7 @@ # Use Exec["concat_$name"] as Semaphor define concatenated_file ( # where the snippets are located - $dir, + $dir = '', # a file with content to prepend $header = '', # a file with content to append @@ -24,11 +23,13 @@ define concatenated_file ( ) { - if defined(File[$dir]) { - debug("${dir} already defined") + $dir_real = $dir ? { '' => "${name}.d", default => $dir } + + if defined(File[$dir_real]) { + debug("${dir_real} already defined") } else { file { - $dir: + $dir_real: source => "puppet://$servername/common/empty", checksum => mtime, recurse => true, purge => true, force => true, @@ -56,11 +57,11 @@ define concatenated_file ( } # use >| to force clobbering the target file - exec { "/usr/bin/find ${dir} -maxdepth 1 -type f ! -name '*puppettmp' -print0 | sort -z | xargs -0 cat ${additional_cmd} >| ${name}": + exec { "/usr/bin/find ${dir_real} -maxdepth 1 -type f ! -name '*puppettmp' -print0 | sort -z | xargs -0 cat ${additional_cmd} >| ${name}": refreshonly => true, - subscribe => File[$dir], + subscribe => File[$dir_real], before => File[$name], - alias => [ "concat_${name}", "concat_${dir}"] , + alias => [ "concat_${name}", "concat_${dir_real}"] , } } -- cgit v1.2.3